el.severo
el.severo

Reputation: 2277

host exception in .htaccess for http to https redirection

I have defined the following code in my .htaccess file, how do I make an exception for http://mydomian.com to not be redirected to https ?

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

(Please note that somewhere on my site I'm loading http://mydomian.com via iFrame and on that website it doesn't have the https working properly).

Upvotes: 1

Views: 109

Answers (1)

Amit Verma
Amit Verma

Reputation: 41209

To exclude www.mydomain.com you can use the following RewriteCondition :

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$

Try this :

RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Upvotes: 1

Related Questions