Yashan Mittal
Yashan Mittal

Reputation: 146

Main domain htaccess is also redirecting addon domain from http to https

I have a main domain that is https site and the addon domain doesn't needs to be https. But due to htaccess now addon domain is also redirecting to https.

This is the code I have in htaccess of main domain-

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [PT,L] 
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

Upvotes: 1

Views: 127

Answers (1)

anubhava
anubhava

Reputation: 785551

You have to add a RewriteCond to restrict first http -> https rule to a particular domain only:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [QSA,L]

Make sure to clear your browser cache before testing this change.

Upvotes: 1

Related Questions