• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Redirect All But One Directory

yavuz

Well-known member
#1
I'm trying to redirect a domain to another using .htaccess but there is one directoy inside the domain that I don't want to redirect:

Code:
## list conditions for redirecitons: by equality or inequality, as needed
RewriteCond %{http_host} !^www.targetsite.net$ [nc]
## a few folders not to be redirected
RewriteCond %{THE_REQUEST} !^.*\/(upload|baddirectory2|baddirectory3)\/*\ HTTP/
## a few pages not to be redirected
RewriteCond %{THE_REQUEST} !^.*\/blah\.html\ HTTP/
RewriteCond %{THE_REQUEST} !^.*\/some-path\/blahbla\.html\ HTTP/

### and so on, whatever conditions
RewriteRule ^(.*)$ http://www.targetsite.com/$1 [r=301,nc,L]
The redirection works but all including the directory I don't want to redirect changes too.