All subdomains are forcefully redirected to https

Hello to everyone,
I have just upgraded to Centos 7 (fresh install) from Centos 5 where i had a domain and one subdomain configured with SSL. Everything worked perfectly, but now, with Centos 7 , seems that i’m missing something since all subdomains of that domain are forcefully redirected to https from http. I googled for this issue and i didnt find anything helpfully. I looked around on httpd.conf to find anything…none :frowning: Now, i don’t have any other alternative but opening a thread here and hope someone can help me on this issue. Is the first time i’m facing this issue (i’m using webmin/virtualmin for 4 years) and i don’t have any clue how to resolve this.
This is my .httaccess

ServerSignature Off
#Options +SymLinksifOwnerMatch
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^12.123.123.123$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domain.tld [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.tld/$1 [R=301,L]
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

BEGIN WPSuperCache

END WPSuperCache

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

Once i remove the .htaccess on the root of the domain, everything works correctly, but with this .htaccess configuration, everything worked correctly before the upgrade. Hope that someone can help me. Thank you!

Howdy,

It’s tough to say why it worked as expected previously… but I’ll offer that your htaccess there is definitely configured to perform a redirect to https.

If that’s not what you want – could you disable the part of the htaccess which is doing the redirecting?

That would be these rules here:

RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^12\.123\.123\.123$ [NC,OR] RewriteCond %{HTTP_HOST} ^domain.tld [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.domain.tld/$1 [R=301,L]

If you don’t need them you could always just comment them out.

-Eric

It looks like you are using WPSuperCache, which has installed a .htaccess file that does the redirection. The rule

RewriteRule ^(.*)$ https://www.domain.tld/$1 [R=301,L]

will redirect everything to an https URL.

One low-tech solution to try would be to simply uninstall WPSuperCache, verify that everything is working correctly, and reinstall it. Reinstalling software is often a very effective solution to all sorts of problems. It’s usually the first thing I try, as it takes only a few minutes and can save a lot of time tracking down the real problem.