Question

I try to redirect the whole website to an other domain, that is working ! But my case need that, if I tried to access to a subfolder (just one), I want to stay at this domain.

Here's my code

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_URI} !administrator

RewriteBase /

RewriteCond %{HTTP_HOST}   ^domaine.com [NC]
RewriteRule ^/?(.*)        http://www.domaine.fr/$1 [QSA,L,R=301]

RewriteCond %{HTTP_HOST}    ^www.domaine.com [NC]
RewriteRule ^/?(.*)         http://www.domaine.fr/$1 [QSA,L,R=301]

This RewriteCond is working in an other project that I took.

So does someone have an idea ?

Thank you !

Was it helpful?

Solution

RewriteBase line cannot come immediately after RewriteCond:

Just one rule will be enough for this task:

Options +FollowSymlinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domaine\.com$ [NC]
RewriteRule ! administrator http://www.domaine.fr%{REQUEST_URI} [NC,L,R=301]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top