简体   繁体   中英

redirect htaccess except a folder

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 !

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM