Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove SSL integration from a specific folder using htaccess

Tags:

ssl

.htaccess

I have an integrated SSL for my entire site and have placed htaccess code to redirect to https when anyone visits my domain URL. But I want to keep one folder out of this redirection to https. Please help me with this... Below is the htaccess code placed in my root to redirect all requests to https counterpart

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Thanks

like image 761
Mudit Dugar Avatar asked Jul 09 '13 02:07

Mudit Dugar


1 Answers

Just add a condition to exclude the folder:

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

And if you wanted to redirect SSL requests to non-SSL for /folder1, then:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/folder1
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
like image 54
Jon Lin Avatar answered Oct 10 '22 10:10

Jon Lin