Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/
</VirtualHost>

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

I tried

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

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

1 Answer 1

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

 
discard

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.