floatleft
floatleft

Reputation: 6541

Force HTTPS except with certain directories

I'm using the following .htaccess file to force any page request to https://

RewriteEngine On
RewriteBase /

#Force SSL
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

How could I modify this script to continue to force https:// except in specified directories like http://example.com/api/ ("api" folder)?

Upvotes: 1

Views: 1159

Answers (1)

Eddy Freddy
Eddy Freddy

Reputation: 1816

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !^/yournonhttpsdirectory/
RewriteRule ^(.*)$ https://www.domain.xyz/$1 [R,L]

maybe this might work?

Upvotes: 1

Related Questions