apache 2.4模块重写错误
尝试使用模块重写生成动态URL,似乎我做错了什么,并得到了服务器错误!服务器遇到内部错误 我用了这个密码apache 2.4模块重写错误,apache,.htaccess,Apache,.htaccess,尝试使用模块重写生成动态URL,似乎我做错了什么,并得到了服务器错误!服务器遇到内部错误 我用了这个密码 <IfModule mod_rewrite.c> #Enable mod_Rewrite RewriteEngine on RewriteBase /project RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP RewriteRule ^(.*)index\.(php|html?)$ $1 [R
<IfModule mod_rewrite.c>
#Enable mod_Rewrite
RewriteEngine on
RewriteBase /project
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
</ifModule>
如果您使用的是无限循环,则两者应加载相同的页面,如下所示: 假设您的apache在某个配置文件中的配置如下:
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml
您的重写规则可能导致:
/project/index.php => /project => /project/index.php => /project => ...
在这种情况下,不需要重写。因此,这里的解决方案是注释掉所有说明:
#<IfModule mod_rewrite.c>
# #Enable mod_Rewrite
# RewriteEngine on
# RewriteBase /project
# RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
# RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
#</ifModule>
#
##启用mod#U重写
#重新启动发动机
#后勤基地/项目
#RewriteCond%{THE_REQUEST}^GET\.*/index\(php | html?)\HTTP
#重写规则^(.*)索引\(php | html?$$1[R=301,L]
#
既然您使用的是Apache2.4,请尝试将
替换为
最后的代码如下所示:
<IfModule rewrite_module>
#Enable mod_Rewrite
RewriteEngine on
RewriteBase /project
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
</ifModule>
#启用mod_重写
重新启动发动机
后勤基地/项目
RewriteCond%{THE_REQUEST}^GET\.*/index\(php | html?)\HTTP
重写规则^(.*)索引\(php | html?$$1[R=301,L]
当然,请确保在.conf文件中注释掉rewrite_module
,以便确实加载它
<IfModule rewrite_module>
#Enable mod_Rewrite
RewriteEngine on
RewriteBase /project
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
</ifModule>