Mod rewrite 多个重写秒,不工作
我有多个重写的顺序,我希望工作,如果/否则。 i、 在纯文本中,它看起来像这样Mod rewrite 多个重写秒,不工作,mod-rewrite,apache2,Mod Rewrite,Apache2,我有多个重写的顺序,我希望工作,如果/否则。 i、 在纯文本中,它看起来像这样 IF there is no Cookie THEN redirect to other host, ELSE, Serve the requested file 我已将条件改写如下: RewriteEngine on #If there is no cookie in the request fwd the request to ABC RewriteCond %{HTTP_COOKI
IF there is no Cookie THEN redirect to other host,
ELSE, Serve the requested file
我已将条件改写如下:
RewriteEngine on
#If there is no cookie in the request fwd the request to ABC
RewriteCond %{HTTP_COOKIE} !^.*Cookie.*$ [NC]
RewriteRule ^(.*)$ http://abc.xyz.com:<port>$1 [P,L]
ProxyPreserveHost On
ProxyPass / http://abc.xyz.com/
ProxyPassReverse / http://abc.xyz.com:<port>/
#else serve the file
RewriteCond %{HTTP:Cookie} ^xxxx-xxxx-xxxx-credentials-a=.*$ [NC]
RewriteRule /([^/]*\.nff).*$ /srv/samba/Assets/$1 [NC,L]
重新编写引擎打开
#如果请求中没有cookie,则将请求转发给ABC
重写cond%{HTTP_COOKIE}!^*Cookie.*$[NC]
重写规则^(.*)$http://abc.xyz.com:$1[P,L]
代理主机
ProxyPass/http://abc.xyz.com/
ProxyPassReverse/http://abc.xyz.com:/
#否则就把文件送达
RewriteCond%{HTTP:Cookie}^xxxx-xxxx-xxxx-credentials-a=.*$[NC]
重写规则/([^/]*\.nff)。*$/srv/samba/Assets/$1[NC,L]
但是,Else RewriteCond不起作用,即使请求头有Cookie,它仍然会被重定向。
我有什么遗漏吗 好的..我在阅读apache文档后找到了解决方案。下面是修改后的代码
RewriteCond %{HTTP:Cookie} ^xxxx-xxxx-xxxx-credentials-a=.*$ [NC]
RewriteRule /([^/]*\.nff).*$ /srv/samba/Assets/$1 [NC,L]
#If there is no cookie in request fwd the request to abc
RewriteRule ^(.*)$ http://abc.xyz.com:<port>$1 [P]
ProxyPreserveHost On
ProxyPass / http://abc.xyz.com/
ProxyPassReverse / http://abc.xya.com:<port>/
RewriteCond%{HTTP:Cookie}^xxxx-xxxx-xxxx-credentials-a=.*$[NC]
重写规则/([^/]*\.nff)。*$/srv/samba/Assets/$1[NC,L]
#如果请求中没有cookie,请将请求转发给abc
重写规则^(.*)$http://abc.xyz.com:$1[P]
代理主机
ProxyPass/http://abc.xyz.com/
ProxyPassReverse/http://abc.xya.com:/
因为只有IF-then-Else,所以不需要使用“Skip”,我需要做的就是停止循环。因此,我在第一条规则中添加了[L],并删除了第二条规则中的其他重写