.htaccess中的循环重定向
我有以下.htaccess文件:.htaccess中的循环重定向,.htaccess,rewrite,no-www,trailing-slash,.htaccess,Rewrite,No Www,Trailing Slash,我有以下.htaccess文件: AddDefaultCharset utf-8 RewriteEngine on Options +SymLinksIfOwnerMatch RewriteBase / # redirect all www-requests to no-www # - RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC] RewriteRule ^(.*)$ http://site.com/$1 [R=301,L] # redirec
AddDefaultCharset utf-8
RewriteEngine on
Options +SymLinksIfOwnerMatch
RewriteBase /
# redirect all www-requests to no-www
# -
RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC]
RewriteRule ^(.*)$ http://site.com/$1 [R=301,L]
# redirect all home pages to / (root)
# -
RewriteCond %{THE_REQUEST} ^.*/index\.(php|html?)
RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,L]
# remove trailing slash from dirs
# -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ /$1 [R=301,L]
# automatically add index.php when needed
# -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|login\.php|reg\.php|robots\.txt|css/|js/)
RewriteRule ^(.*)$ /index.php [L]
.htaccess文件应执行以下操作(对于SEO):
http://www.site.com
应该变成http://site.com
)http://site.com/me/
应该被重定向http://site.com/me
index.php/index.html
的URI都应该转换为nothing:http://site.com/admin/index.php
或http://site.com/admin/
最终应显示为http://site.com
http://site.com/admin
)。浏览器应该获取的真实文档是http://site.com/admin/index.php
有人能帮我解决这个问题吗?有一个名为mod_dir的模块,它会自动加载,并导致对缺少尾部斜杠的目录的请求用尾部斜杠重定向。您可以使用该指令将其关闭,但在关闭时请注意安全警告。如果将其关闭并且无法加载默认索引,则会出现信息披露安全问题。但是,您的lats规则(看起来)是这样的,尽管它不正确 首先,关闭
目录slash
DirectorySlash Off
然后,您需要将最后一条规则更改为:
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}/index.php -f
RewriteRule ^(.*)$ /$1/index.php [L]