We're migrating from one subdomain to another. This particular domain has a subset of several websites. I've setup the following rewrite to handle the redirect globally:
In docroot/.htaccess
("Rule #1")
RewriteEngine On
RewriteCond %{HTTP_HOST} ^virtual\.example\.com$
RewriteRule ^(.*)$ http://events.example.com/$1 [L,R=301]
It generally works, except for a few sites which have their own rewrite rules. For example, /roadshow/2015/
has the following catch-all rule:
In docroot/roadshow/2015/.htaccess
("Rule #2")
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.php$
RewriteRule .* framework/main.php?url=%1&%{QUERY_STRING} [L]
The problem: Pages under /roadshow/2015/
continue to load as if Rule #1 doesn't exist.
What am I missing here? :)
mod_rewrite directives in .htaccess files in subfolders will trump ones in parent folders - try using
RewriteOptions Inherit
in each subfolder's .htaccess file (see http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions).If you're running Apache 2.4.8 or higher, you can use RewriteOptions InheritDown to apply to all child .htaccess files automatically rather than having to modify each one.