Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
apache htaccess检查cookie重定向错误500_Apache_.htaccess - Fatal编程技术网

apache htaccess检查cookie重定向错误500

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

我需要实现的功能,当用户被重定向到一个登录页面取决于特殊的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
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]