Not sure I am posting at the right location :)

I want to be able for instance to redirect http://www. example.com (with www) to http:// example.com/fr (without www, AND subdirectory)

Of course, I also want http:// example.com to redirect to http:// example.com/fr

What I have so far is this :

RewriteBase / RewriteRule ^index\.php$ - [L] 
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ example.com/fr/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^example.com [NC] 
RewriteRule ^(.*)$ example.com/fr/$1 [L,R=301,NC]

It does a permanent loop though... How can I fix this ?

Thank you ! :)

marked as duplicate by Tero Kilkanen, HBruijn Nov 27 '16 at 8:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


What about this:

RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/fr/.*$
RewriteRule ^(.*)$ /fr/$1 [L,R=301,NC]
  • Thank you. Don't forget to accept the answer and upvote :) – Diego Roccia Nov 25 '16 at 20:40
  • Well I think I've spoken too fast. It slows down like crazy the load speed of my website... :( Actually apart from the <title> nothing loads ever, Firefox keeps working but nothing appears. Any solution ? – Lisa Lucas Nov 28 '16 at 19:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.