【发布时间】:2015-09-25 13:46:36
【问题描述】:
我正在尝试编写一个 htaccess 规则以将所有内容重定向到 /admin,除非它是 /users/*
这是我目前所拥有的,但是有一个重定向循环,我不知道为什么:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteCond %{REQUEST_URI} !^/users [NC]
RewriteRule ^(.*)$ /admin [R=301,L,NC]
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^sitemap.xml$ /sitemap [L,P]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
【问题讨论】:
标签: php regex .htaccess mod-rewrite