Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following Apache virtual host which redirects all traffic to the secure version of the site:

<VirtualHost *:80>
    DocumentRoot "C:/Web/"
    ServerName site.local
    ErrorLog "C:/Webserv/Apache2.2/logs/site_error.log"
    CustomLog "C:/Webserv/Apache2.2/logs/site_access.log" combinedvh

    Redirect / https://site.local/

I would now like to exclude certain directories from the redirect.

I tried

    <DirectoryMatch "!^C:/Web/myfolder/">
        Redirect / https://site.local/

but then nothing is redirected to secure.

Is there an easy way to do this?
I do not want to end up with separate Redirect directives for every subfolder, especially since I want to redirect the root folder too.

share|improve this question
up vote 3 down vote accepted

Maybe you should use mod_rewrite, something like this:

RewriteCond %{REQUEST_URI} !^/myfolder
RewriteRule (.*) https://site.local/ [L,NC]
share|improve this answer

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.