我想要一种非常简单的方法来指导没有特定cookie值的所有用户。我尝试了以下代码,它重定向,然后转到我的ISP页面找不到启动页面
RewriteEngine on
RewriteCond %{HTTP_COOKIE} ^user=(admin)$ [NC]
RewriteRule .* http://www.example.com/%1 [R=301,L]
RewriteRule .* http://www.example.com/login.php [R=301,L]
我没有任何其他规则。我在服务器上也只有两页。它被重定向到login.php然后我得到以下firefox错误
The page isn't redirecting properly.
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies
答案 0 :(得分:0)
您需要添加一些条件以防止循环:
RewriteEngine on
RewriteCond %{HTTP_COOKIE} ^user=(admin)$ [NC]
RewriteCond $1 !^admin
RewriteRule ^(.*)$ http://www.example.com/%1 [R=301,L]
RewriteCond $1 ^login\.php
RewriteRule ^(.*)$ http://www.example.com/login.php [R=301,L]