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.
Hope that someone can help me.
Thank you!



Joe's picture
Submitted by Joe on Sat, 01/23/2016 - 22:57 Pro Licensee

Are there any .htaccess files that might be making the redirect happen? They'd be in the public_html of the sites in question.

Hello @Joe, This is the .htaccess:

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]

# END WordPress

Thank you!

Ah, it appears likely your htaccess file is causing the redirects. You may want to confirm that by temporarily renaming your htaccess file and see if that continues to occur.

The first RewriteCond and RewriteRule lines are the likely culprits.

Are you using Virtualmin GPL there though? If you're using Virtualmin GPL, and you had any followup questions, you'd actually want to ask those in the Forums. We monitor the Forums, along with lots of wonderful folks from the community. Thanks!

Hello there,
@andreycheck , Yep...I'm using Webmin/Virtualmin on that server. When i rename the .htaccess, it works perfectly. I should mention that with the same configuration of .htaccess, on the centos 5 and virtualmin, it worked perfectly. After the upgrade to Centos7, appeared that problem. I have commented the first RewriteCond you suggested and the RewriteRule and the problem persists :-(
You suggested to move the issue on the forum!? If you think that's better, I Will.
Thank you!