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.

link|improve this question

feedback

1 Answer

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]
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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