All subdomains are forcefully redirected to https

3 posts / 0 new
Last post
#1 Tue, 02/16/2016 - 11:17
Kleidi

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 :-( 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
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# 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!

Tue, 02/16/2016 - 12:25
andreychek

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

Tue, 02/16/2016 - 12:32
joe443

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.

Topic locked