2

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.

1 Answer 1

3

Maybe you should use mod_rewrite, something like this:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .