Uffe Kousgaard
Uffe Kousgaard

Reputation: 739

How do I do https for a whole website, except for one folder?

I have this htaccess file, which rewrites everything to https:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Is it possible to make an exception for a single folder, so it runs on normal http?

Upvotes: 0

Views: 22

Answers (1)

MaartenDev
MaartenDev

Reputation: 5802

The following RewriteCond can be used:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/test/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Uses http for:

http://example.com/test/abc.txt

but redirects to https for:

http://example.com/hello/abc.txt

Upvotes: 1

Related Questions