重定向* .PHP清洁网址重定向、清洁、网址、PHP

2023-09-02 00:19:53 作者:倚栏清风

我的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应该重定向到/胡说/约

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.

重定向工作正常,但我在/胡说得到一个内部服务器错误/约

The redirect works fine but I get an internal server error in /blah/about

**编辑 - 错误日志:

** Edit - error log:

请求超过了10内部重定向的限制,由于可能的配置错误。使用'LimitInternalRecursion'如果有必要提高限制。使用LogLevel的调试,以得到一个回溯。

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]