RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
# Turn SSL on for /user/login
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/admin/rest_api
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Turn SSL off everything but /user/login
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/admin/rest_api
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Disable .htaccess rule to a specific directory
Question
I have a Rule in My base folder .htaccess file. The rule will automatically redirect http:// to https://. But for a specific folder or URL I need to access through http://
RewriteRule ^(.*)$ https:/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
For example My website will be like https://<>/power/a/1
But I need to access some URL without https://
Solution 2
OTHER TIPS
You need to implement an "exception rule" in form of a condition for the RewriteRule
:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/webservices/access
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This should work:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/webservices/access
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It will redirect everything but the /webservices/access
folder (or any other links in that folder like /webservices/access/login.php
) to https
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow