Can anyone help me achieve a redirect in Apache from http://subdomain.example.com/ to http://example.com/ for all URLs, EXCEPT the ones starting with "files/"? Thank you
Asked
Active
Viewed 607 times
1 Answers
2
Put the code below in subdomain.example.com
virtual host section:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com [NC]
RewriteCond %{REQUEST_URI} !/files
RewriteRule ^(.*)$ http://example.com%{REQUEST_URI} [R=301,L]
-
Thanks for your answer. The problem is that both subdomains have the same document root. Is there any way I could prevent infinite redirection for the example.com? – bogdan Sep 26 '11 at 08:02
-
You can check `%{HTTP_HOST}`. – quanta Sep 26 '11 at 08:13