Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess如果cookie未退出,则重定向_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess如果cookie未退出,则重定向

.htaccess如果cookie未退出,则重定向,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,因此,我在文件夹dev中有index.html和login.html,例如:http://www.example.com/dev/login.html 我需要的是每次用户进入http://www.example.com/dev/index.html或http://www.example.com/dev/for.htaccess检查cookie登录名是否等于1,以允许用户访问,否则将用户重定向到 http://www.example.com/dev/login.html 这就是我到目前为止所得到的

因此,我在文件夹
dev
中有
index.html
login.html
,例如:
http://www.example.com/dev/login.html

我需要的是每次用户进入
http://www.example.com/dev/index.html
http://www.example.com/dev/
for.htaccess检查cookie
登录名是否等于1,以允许用户访问,否则将用户重定向到
http://www.example.com/dev/login.html

这就是我到目前为止所得到的,如果用户转到,它会工作,但如果用户输入,它不会重定向

RewriteCond %{REQUEST_URI} ^/dev/$    
RewriteCond %{HTTP_COOKIE} !login=2;?
RewriteRule ^(.*)$ /dev/login.html [R=302,L]

/dev/working和/dev/index.html不工作的原因是因为
重写cond%{REQUEST_URI}^/dev/$
^/dev/(?:index\.html)$