jeudi 16 avril 2015

htaccess reposition a part of a url

Hello I have a website that should be available in multiple languages. I made it with wordpress. What I am trying to achieve is that every language get its own (virtual) subdomain. So for example fr.foo.eu and nl.foo.eu.


At the moment i have the urls in the following format: foo.eu/?lang=nl foo.eu/?lang=fr


It is possible that there is more content in the url for example: http://ift.tt/1FSxR4V


And i would like to have my urls the following way using htaccess:



http://ift.tt/1FL0iMW


Could you guys help me with achieving that.


Here is what i have so far in my .htaccess:



<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^([a-z]{2}\.hypnose\.eu$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^\?]*)\?lang=([a-z]{2})&?([^\ ]*)
RewriteRule ^ http://%2.hypnose.eu/%1?%3 [L,R]

RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteCond %{HTTP_HOST} ^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteRule ^(.*)$ /$1?lang=%2 [L,QSA]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]
</IfModule>

Aucun commentaire:

Enregistrer un commentaire