Redirect site to HTTPS excluding a folder

Written by Yujin Boby

Edit in WordPress

On a web site, customer need to redirect all pages to HTTPS, but want to keep files in one of the folder on HTTP.

For this, i used following in .htaccess file.

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

Here any url like yourdomain.extn/auth/ will not get redirected to HTTPS.

See Redirect