Blynn
Blynn

Reputation: 1411

.htaccess redirect cookie to new url for all ending urls

So the site detects the cookie = uk okay but when I'm trying to redirect

from: http://example.com/page/page-name to: http://example.com/uk/page/page-name

no url is working the way I was hoping adding in the /uk/ it appears to be adding in a index.php for some reason.

RewriteEngine On
RewriteCond %{HTTP_COOKIE} country=uk; [NC]
RewriteRule ([^/])/uk/?        /$1$2/ [L,R=301]

Upvotes: 1

Views: 24

Answers (1)

anubhava
anubhava

Reputation: 785246

You can use this rule:

RewriteEngine On

RewriteCond %{HTTP_COOKIE} country=uk; [NC]
RewriteRule !^uk/ /uk%{REQUEST_URI} [L,R=301,NE,NC]

Upvotes: 1

Related Questions