Reputation: 103
I tried searching in first here in stackoverflow and google for the best answer but I could not find a solution to my problem.
My question is can I add a condition where a specific sets of folder/files in my server will not be affected by a htaccess 301 redirection from old domain to new domain?
this is the htaccess I added.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !mysite.com.au$ [NC]
RewriteRule ^(.*)$ http://mysite.com.au/$1 [L,R=301]
the old domain was mysite.com without the .au and the above code will direct all links in my old site to be transfer to .com.au , but I want some of my folder in .com to be not affected by the htaccess 301 redirection, for example.
mysite.com/folder1/,
mysite.com/images/,
mysite.com/js/
and some files will not be affected by this redirection. Can any one point me to on how to fix or add a rule so a specific folder will not be affected by the old domain to new domain htaccess 301 redirection I added?
thanks,
Upvotes: 2
Views: 503
Reputation: 785176
You can add a RewriteCond
in your redirect rule for exceptions:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(folder/|images/|js/) [NC]
RewriteCond %{HTTP_HOST} !^mysite\.com\.au$ [NC]
RewriteRule ^ http://mysite.com.au%{REQUEST_URI} [NE,L,R=301]
Upvotes: 1