我想以一种非常简单的方式来指导所有没有特定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发布于 2014-09-30 06:16:48
您需要添加一些条件来防止循环:
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]https://stackoverflow.com/questions/26106323
复制相似问题