5

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).

Cœur
  • 37,241
  • 25
  • 195
  • 267
user546585
  • 129
  • 4
  • 9

1 Answers1

8

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.

Christopher
  • 2,005
  • 3
  • 24
  • 50