Wordpress not redirecting from http to https

Scorpion Ghost

Elite Member
Executive VIP
Jr. VIP
Joined
Mar 22, 2013
Messages
8,716
Reaction score
10,282
So I have an old wordpress site, and recently I migrated hosting, and I noticed that my pages don't redirect from http to https. I don't think it was like this before, and I can't figure out how to fix it.

Only the homepage actually redirects properly. So if I visit http://mysite.com, it will automatically redirect to https://mysite.com. Also, all the links on the entire site are https by default. However, if I manually visit http:// for any page on the site except the hompage, it actually opens it in http:// and does not open it with https://

I tried multiple things I found online, adding in the .httacess file, but nothing works.

My .htaccess file is in the root folder of the site, it's not in the theme's folder (wp-content, themes, MyTheme). This is what's in it:

Code:
# BEGIN WordPress
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType text/html "access plus 5 minutes"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
Options -Indexes

                <IfModule mod_rewrite.c>
                    RewriteEngine On
                    RewriteBase /
                    RewriteRule ^/http:/mysite.com/wp-content/endurance-page-cache/ - [L]
                    RewriteCond %{REQUEST_METHOD} !POST
                    RewriteCond %{QUERY_STRING} !.*=.*
                    RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
                    RewriteCond %{DOCUMENT_ROOT}/http:/mysite.com/wp-content/endurance-page-cache/$1/_index.html -f
                    RewriteRule ^(.*)$ /http:/mysite.com/wp-content/endurance-page-cache/$1/_index.html [L]
                </IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
</IfModule>

# END WordPress

I want all pages to redirect to https://, even if I manually visit in http://

Any ideas?
 
Last edited:
Check your Wordpress address settings, make sure the default address is https://
 
If you using cpanel. Go to your domain and choose the redirect to HTTPS
 
If you using cpanel. Go to your domain and choose the redirect to HTTPS

I am using panel. Where do I go to my domain and redirect to https? Like, in cPanel in addon domains, where exactly?

you can try really simple ssl or similar plugins. Just search on the wordpress plugin vault.

I could, but I prefer to not use plugins for things that can be accomplished without a plugin.
 
go to your domain provider do a full 301 that simple .
 
force it stop being a baby

add this to your htaccess

Code:
RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


The .htaccess file needs to be located inside the site's document root folder.
 
+1 for Really Simple SSL
Also, check the website from another browser.
 
force it stop being a baby

add this to your htaccess

Code:
RewriteEngine On

RewriteCond %{HTTPS} off

RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


The .htaccess file needs to be located inside the site's document root folder.

I already tried that. I tried it again. Still doesn't redirect.

Current htaccess code:

Code:
# BEGIN WordPress
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType text/html "access plus 5 minutes"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
Options -Indexes

                <IfModule mod_rewrite.c>
                    RewriteEngine On
                    RewriteBase /
                    RewriteRule ^/http:/mysite.com/wp-content/endurance-page-cache/ - [L]
                    RewriteCond %{REQUEST_METHOD} !POST
                    RewriteCond %{QUERY_STRING} !.*=.*
                    RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
                    RewriteCond %{DOCUMENT_ROOT}/http:/mysite.com/wp-content/endurance-page-cache/$1/_index.html -f
                    RewriteRule ^(.*)$ /http:/mysite.com/wp-content/endurance-page-cache/$1/_index.html [L]
                </IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]

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

</IfModule>

# END WordPress
 
Are you already clear the website cache or browser cache ?
Are this site is using CDN like cloudflare ?
 
Are you already clear the website cache or browser cache ?
Are this site is using CDN like cloudflare ?

I'm not using cloudflare.

I reloaded the site multiple times with a hard refresh that bypasses the cache, and also tried other browsers. I don't think it's a website or browser cache issue. Also because if I remove a piece of code from the htacess file even my homepage doesn't redirect to https. When I return the code, it redirects. So it's not a cache issue.
 
I'm not using cloudflare.

I reloaded the site multiple times with a hard refresh that bypasses the cache, and also tried other browsers. I don't think it's a website or browser cache issue. Also because if I remove a piece of code from the htacess file even my homepage doesn't redirect to https. When I return the code, it redirects. So it's not a cache issue.

Try for using this code on the bottom of .htaccess file

HTML:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

Hope can solve the problem
 
very strange .

is it a free https certificate ?

how your https setup sounds like it wrongly setup .
 
very strange .

is it a free https certificate ?

how your https setup sounds like it wrongly setup .

Yes https is free, offered by hostgator. And they set it up, so I didn't set it up other than to do some simple changes for photos that are hardcoded. And that was over a year ago, maybe two years.
 
did you try this method to setup https.

https://www.blackhatworld.com/seo/guide-how-to-setup-free-ssl-on-shared-hosting.922130/


you said it all hostgator shit host sorry always problams it there shit servers

when i was doing programming hostgator was number 1 problam .

sorry can not help it your provider .

there staff are useless same as there server setup .

there dns servers and database servers are so slow and there php rules are shit .

looks like there https certificate are setup shit aswell sorry contact them.
 
Last edited by a moderator:
This has been fixed. A friend of mine went in there and fixed it for me. Here, in case anyone ever runs into this thread with a similar issue, no friends and no money.

Old htaccess:

Code:
# BEGIN WordPress
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType text/html "access plus 5 minutes"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
Options -Indexes

                <IfModule mod_rewrite.c>
                    RewriteEngine On
                    RewriteBase /
                    RewriteRule ^/http:/mysite.com/wp-content/endurance-page-cache/ - [L]
                    RewriteCond %{REQUEST_METHOD} !POST
                    RewriteCond %{QUERY_STRING} !.*=.*
                    RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
                    RewriteCond %{DOCUMENT_ROOT}/http:/mysite.com/wp-content/endurance-page-cache/$1/_index.html -f
                    RewriteRule ^(.*)$ /http:/mysite.com/wp-content/endurance-page-cache/$1/_index.html [L]
                </IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
</IfModule>

# END WordPress

New htaccess:

Code:
# Force SSl and non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
# Force SSl and non-www

# Gasimo EIG govna
 
Header set X-Endurance-Cache-Level "0"

# BEGIN WordPress

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

# END WordPress

#KOMPRESIJA I EXPIRY HEADERS


<IfModule mod_deflate.c>
Addtype font/opentype .otf
Addtype font/truetype .ttf

# Komprimiere HTML, CSS, JavaScript, Text, XML und fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE application/json

 
  # Browser bugs entfernen (nur f端r wirklich alte Browser)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
  Header append Vary: Accept-Encoding
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"

# Data
  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"

# Favicon (cannot be renamed)
  ExpiresByType image/x-icon              "access plus 1 week"

# Media: images, video, audio
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  ExpiresByType video/webm                "access plus 1 month"

# Webfonts
  ExpiresByType application/x-font-ttf    "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 year"
  ExpiresByType application/javascript    "access plus 1 year"
  ExpiresByType application/x-javascript    "access plus 1 year"

</IfModule>

I'm not sure if my friend did any edits other than the htaccess file. I was sleeping when he fixed it, and he's not here now to ask him. But I don't think he did, it's only the htacess file edit that solved the problem.

Ok, I'm glad I didn't have to spend hours and hours and/or money to fix this.

Solved and solved. Done and done :)

Oh, also, women and smart and funny you guys, get over it! :D

 
Back
Top