Lzhelenin
Lzhelenin

Reputation: 193

Add a specific part to url using .htaccess

I guess it's an easy question but I hardly know syntax used in .htaccess, so I got a bit stuck. How to add '/de/' after a domain name in this case, so the result will be something like 'blablabla.com/de/blog' or 'blablabla.com/de/offices' instead of 'blablabla.com/blog' and 'blablabla.com/offices'?

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} lang=de [NC]

</IfModule>

I know that there should be RewriteRule after RewriteCond but, as I've said before, I'm not familiar with the syntax...

Upvotes: 1

Views: 61

Answers (2)

Croises
Croises

Reputation: 18671

You can use:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} lang=de [NC]
RewriteCond %{REQUEST_URI} !^/de/ [NC]
RewriteRule ^(.*)$  /de/$1  [R,L]

</IfModule>

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41219

To access your site urls with /de segment ,you can use :

RewriteEngine On
RewriteBase /
RewriteRule ^de/(.+)$ /$1 [NC,L]

Upvotes: 0

Related Questions