Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Can anyone help me achieve a redirect in Apache from to for all URLs, EXCEPT the ones starting with "files/"? Thank you

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Put the code below in virtual host section:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com [NC]
RewriteCond %{REQUEST_URI} !/files
RewriteRule ^(.*)${REQUEST_URI} [R=301,L]
share|improve this answer
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 –  bogdanvursu Sep 26 '11 at 8:02
You can check %{HTTP_HOST}. –  quanta Sep 26 '11 at 8:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.