I was wondering how to exclude a subfolder from .htaccess redirect.
I have an .htaccess file in the root of my old domain and I have the following in it:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
This of course redirects any traffic from the old domain to the new one. But I want to exclude a directory from this rule. Meaning www.olddomain.com/media/videos should not redirect to www.newdomain.com/media/videos
The reason I want the exclusion is because I'm hosting static files such as videos on a shared web server (old domain) and I'm keeping everything else the site needs on the new VPS server (new domain).
Just put RewriteCond %{REQUEST_URI} !^/media/videos
above your RewriteRule. It checks wether the URL starts with /media/videos
and if it does so, the RewriteRule will not be met.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With