Hi All,
I have to redirect page A to page B if cookie is not present. If cookie is present then this redirection will not happen.
I need to redirect to page B before request reaches to AEM server.
How can we do this on dispatcher?
Any pointers highly appreciated.
Thanks,
Pradeep
Solved! Go to Solution.
Views
Replies
Total Likes
Hi All,
Finally it worked
RewriteCond %{HTTP_COOKIE} !mycookie
RewriteRule ^/(.*)/test-project/page1(.*?) /$1/page3 [QSA,L,R,NE]
RewriteRule ^/(.*)/test-project/page2(.*?) /$1/page3 [QSA,L,R,NE]
Thanks,
Pradeep
You can try with apache rewrite engine . Tweak the below code and can try
RewriteEngine On RewriteCond %{HTTP_COOKIE} ^.*COOKIENAME=COOKIEVALUE.*$ RewriteRule ...
Also another link that might be useful for you here
https://stackoverflow.com/questions/6021552/check-cookie-and-redirect-with-apache
Hi @pradeepdubey82 ,
Please try below-
RewriteCond %{HTTP_COOKIE} mycookie
RewriteRule .* /page-A.html?redirectTo=/page-B.html [QSA,L,R,NE]
Where mycookie is the cookie name.
Thanks,
Ritesh Mittal
You can use the usual rewrite module of the Apache to do so -
Use mod_rewrite with a RewriteCond
that checks the HTTP_COOKIE
variable and then rewrite as desired, for example:
RewriteEngine on RewriteCond %{HTTP_COOKIE} cookie=([a-zA-Z]+) RewriteRule .* http://mydomain.com/NEW-LOCATION/%1 [R=301,L]
Here the value of cookie can be any custom value.
Hi All,
Finally it worked
RewriteCond %{HTTP_COOKIE} !mycookie
RewriteRule ^/(.*)/test-project/page1(.*?) /$1/page3 [QSA,L,R,NE]
RewriteRule ^/(.*)/test-project/page2(.*?) /$1/page3 [QSA,L,R,NE]
Thanks,
Pradeep