Reputation: 8685
I have installed an SSL certificate on a website running Expression Engine, and added the following .htaccess rules to redirect http to https:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
This works fine, except that I've just discovered this breaks the css in the control panel. I'm not sure why. But removing these .htaccess rules allows it to work properly again.
Therefore, is it possible to have the same rules as above, but add an exception for all URLs beginning with /admin.php
?
Upvotes: 1
Views: 36
Reputation: 4917
Yes, it is !
Just add this condition to your rules:
RewriteCond %{REQUEST_URI} !^/admin.php [NC]
So for example, if someone enters a URL like: http://example.com/admin.php
it will NOT redirect to HTTPs.
In addition, you can also remove the extra rewrite that you have so that your server has less to load. You don't have to do it, just an extra option for you:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{REQUEST_URI} !^/admin.php [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Upvotes: 1