apache 目录级的URL重写支持

本文介绍了当遇到Apache服务器返回The requested URL was not found错误时的解决方案。主要涉及如何正确配置Apache服务器的.htaccess文件及httpd.conf文件,确保rewrite_module模块被正确启用。包括在Linux环境下修改配置文件的具体步骤,以及在Windows环境下对应的配置更改。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、问题

运行项目使出现The requested URL /regiser was not found on this server.就是因为apache的重写未开启。

2、解决方法

1)、Linux下配置文件中

<Directory "/var/www/gongsc/public">

    Options FollowSymLinks

    DirectoryIndex index.php index.html index.htm

    #注意这个地方的配置,会影响本地目录下的.htaccess的启用。使用 All
    AllowOverride All 

    Order deny,allow

    Allow from All

</Directory>

然后安装模块rewrite_module

sudo a2enmod rewrite

重启服务器

2)apache 打开 httpd.conf 文件

#LoadModule rewrite_module modules/mod_rewrite.so

去掉前面的#号

找到

<Directory "E:/online/webs/Apache24/htdocs">

Options Indexes FollowSymLinks

AllowOverride None =>改为 AllowOverride All

Order allow,deny

Allow from all

</Directory>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值