Redirect using htaccess based on cookies?

if the user opens example.com
need to check if he has a cookie and if there is - then redirect example.com/cookie_value
but to do nothing is after the slash there's something type example.com/post/123
June 7th 19 at 14:43
1 answer
June 7th 19 at 14:45
RewriteCond %{REQUEST_URI} !post/123$
RewriteRule ^/cookie_value$ /tutotial/? [L,R=301]
it is not quite that, I just moved here, but not yet finished

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_COOKIE} ^.*MyCook=(\d+).*$ [NC]
RewriteRule .* 127.177.0.2/$1 [R=301,L]

RewriteRule .* app.php

it is necessary to have validated MyCook as 6 symbols and not numbers - erna_Bergstr commented on June 7th 19 at 14:48
,
[0-9]{6} - six characters
[0-9]{1,6} - from one to six
[0-9]{1,} - one - Lavern_Schuppe commented on June 7th 19 at 14:51
,

somehow RewriteRule .* 127.177.0.2/$1 not substitutes instead of $1 the value of cookies. instead redirects to / and the result is an endless redirect

also tried with %1

what's wrong? - erna_Bergstr commented on June 7th 19 at 14:54
http://127.177.0.2 - Lavern_Schuppe commented on June 7th 19 at 14:57
, how do I do a redirect to the same host only /cookie_value ? - erna_Bergstr commented on June 7th 19 at 15:00
at least make it right
for a start
all of the rule is $1
all of that Konda is %1

Now to your that is where the first groupaa in the steering wheel ?, what do you want ?
RewriteCond %{HTTP_COOKIE} ^.*MyCook=(\d+).*$ [NC]
RewriteRule .* 127.177.0.2/$1 [R=301,L]

Now you're trying to pass on the IP and Protocol of who for you to indicate will happen? you don't change the url and host name and it is written with the Protocol! - Lavern_Schuppe commented on June 7th 19 at 15:03
Yes there above the old code, I added the Protocol

all of the rule is $1
all of that Konda is %1


I don't have not from HR and not from Konda.
I have to get the value of a cookie? - erna_Bergstr commented on June 7th 19 at 15:06
%{HTTP_COOKIE} you have at least RweriteCond - Lavern_Schuppe commented on June 7th 19 at 15:09

Find more questions by tags Apachehtaccess