我正在开发一个带有 htaccess 规则的网站。这是网址结构:
example.com
example.com/index.php/login
example.com/index.php/foo
demos.example.com
对于上面的最后一个 url (demos.example),我想显示 .htaccess 的内容example.com/index.php/demos
,因此,我创建了一个 .htaccess 文件,如下所示:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?demos.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/demos [L]
当我浏览demos.example.com
索引页面时显示(example.com),因为没有发生任何事情。我希望我的解释很清楚。
更新
如果我使用 .htaccess 如下:
RewriteCond %{HTTP_HOST} ^(www\.)?demos\.example\.com
RewriteRule ^(.*)$ index.php/demos/$1 [L]
...这使得浏览器显示一个500 internal server error
. 查看日志,它会打印以下消息:
[Thu Dec 06 15:06:24 2012] [error] [client 201.192.30.254] 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., referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3112): [client 201.192.30.254] r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/demos/, referer: http://example.com/
[Thu Dec 06 15:06:24 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /, referer: http://example.com/