我遇到了htaccess问题。
以下是我的要求:
1)pages / PAGE(没有斜杠)## page.php?page = PAGE
2)pages / PAGE / DATA(无斜尾)## page.php?page = PAGE& data = DATA
3)登录,注销,索引(无.php或/)
4)页面(带或不带斜线)重定向到登录(无斜线或.php)
这就是我目前所尝试的:
RewriteEngine On
RewriteRule ^logout$ pages/logout.php [NC,L]
#1
RewriteRule ^pages/(\w+)$ page.php?page=$1 [NC,L]
#2
RewriteRule ^pages/(\w+)/(\w+)$ page.php?page=$1&data=$2 [NC,L]
#3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RedirectMatch 301 ^(.*)/$ $1
这个问题是root给了我' Redirect loop'
页面(有或没有尾随/)给我一个重定向循环
答案 0 :(得分:0)
你的规则如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=302,L]
RewriteRule ^logout$ pages/logout.php [NC,L]
#1
RewriteRule ^pages/(\w+)$ page.php?page=$1 [NC,L]
#2
RewriteRule ^pages/(\w+)/(\w+)$ page.php?page=$1&data=$2 [NC,L]
#3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]