apache htaccess检查cookie重定向错误500
我需要实现的功能,当用户被重定向到一个登录页面取决于特殊的cookie。我做了以下工作:apache htaccess检查cookie重定向错误500,apache,.htaccess,Apache,.htaccess,我需要实现的功能,当用户被重定向到一个登录页面取决于特殊的cookie。我做了以下工作: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_COOKIE} !^hehehe [NC] RewriteRule ^ / [NC,L] # To externally redirect /dir/foo.php to /dir/foo
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} !^hehehe [NC]
RewriteRule ^ / [NC,L]
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.html -f [NC]
RewriteRule ^ %{REQUEST_URI}.html [L]
当出现名为hehehe的cookie时,我希望重定向到索引页。但我得到了错误500。如何修复此问题?这当然是因为在尝试显示索引页时,cookie也存在,并且它会一次又一次地重定向到同一页 尝试:
RewriteCond %{HTTP_COOKIE} !^hehehe [NC]
RewriteRule !^$ / [R=302,NC,L]
这当然是因为cookie在尝试显示索引页时也存在,并且会一次又一次地重定向到同一页 尝试:
RewriteCond %{HTTP_COOKIE} !^hehehe [NC]
RewriteRule !^$ / [R=302,NC,L]
谢谢,但是如果我把hehehe改为_sd_c_I(带破折号),它就不起作用了。知道为什么吗?试试
RewriteCond%{HTTP_COOKIE}_sd_c_i[NC,NE]
谢谢,但是如果我把hehehe改为_sd_c_i(带破折号),它就不起作用了。知道为什么吗?试试RewriteCond%{HTTP_COOKIE}_sd_c_i[NC,NE]