将 *.php 重定向到清理 URL [英] Redirect *.php to clean URL
问题描述
我的 htaccess 不太好用:
My htaccess doesn't quite work:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).php$ /blah/$1 [R=301,L]
RewriteRule ^(.*)$ /blah/index.php/$1 [L]
基本上/blah/about.php 应该重定向到/blah/about
Basically /blah/about.php should redirect to /blah/about
我使用的是 codeigniter,所以最后一行是处理 URL 所必需的.
I'm using codeigniter so the last line is required to process URL's.
重定向工作正常,但我在/blah/about 中收到内部服务器错误
The redirect works fine but I get an internal server error in /blah/about
** 编辑 - 错误日志:
** Edit - error log:
由于可能的配置错误,请求超出了 10 个内部重定向的限制.如有必要,请使用LimitInternalRecursion"来增加限制.使用LogLevel debug"获取回溯.
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
推荐答案
感谢 @Cryo 的帮助,这是解决方案:
Thanks @Cryo for his help, this is the fix:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).php$ /blah/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blah/index.php/$1 [L]
这篇关于将 *.php 重定向到清理 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!