Por*_*oru 2 apache mod-rewrite
我的文件夹结构:
- nameoftherootfolder
-- app
-- public
--- .htaccess
--- index.php
Run Code Online (Sandbox Code Playgroud)
现在我遇到的问题是,在某些情况下,我的apache经常重写内部,我得到500服务器错误,这里是日志:
[Wed Jan 05 17:51:54 2011] [error] [client 127.0.0.1] Request exceeded the limit of 3 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Jan 05 17:51:54 2011] [debug] core.c(3046): [client 127.0.0.1] r->uri = /nameoftherootfolder/public/index.php
[Wed Jan 05 17:51:54 2011] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /nameoftherootfolder/public/index.php
[Wed Jan 05 17:51:54 2011] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /nameoftherootfolder/public/index.php
[Wed Jan 05 17:51:54 2011] [debug] core.c(3052): [client 127.0.0.1] redirected from r->uri = /nameoftherootfolder/nothere/
Run Code Online (Sandbox Code Playgroud)
我的.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Run Code Online (Sandbox Code Playgroud)
如果访问的url错误,index.php处理所有请求并处理,例如不存在.
它是有效的,如果访问的网址存在,但它的网址是"错误的"我得到了该错误.我得到这个就是因为我设置了一个Apache别名:
Alias /nameoftherootfolder/ "C:/somepathshere/WAMP/www/nameoftherootfolder/public/"
<Directory "C:/somepathshere/WAMP/www/nameoftherootfolder/public/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
我现在如何使用Apache防止过多的内部重定向?可能有RewriteCond吗?我正在使用Apache 2.2.11.
编辑:
如果我把它index.php/
放在uri里面它可以工作,但那是SEO不友好,用户不友好,看起来很可怕,例如请求.
http://localhost/nameoftherootfolder/index.php/nothere/
要么http://localhost/nameoftherootfolder/index.php/index/
编辑#2:
我加了之后
RewriteBase /nameoftherootfolder/
Run Code Online (Sandbox Code Playgroud)
它的作品知道.
归档时间: |
|
查看次数: |
10835 次 |
最近记录: |