Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1522

WordPress Force Redirect to HTTPS Not Working on Some Pages

$
0
0

I want my website to always show "https://www.example.com." If a user clicks a URL in a different format, it must redirect to the full URL with "www" and "https."

I tried to force my WordPress website to always use "https" by updating the .htaccess file. I found that the redirection works for most cases, but some URLs, like "http://example.com/category," don't redirect properly.

However, if I add a trailing slash to the URL, like "http://example.com/category/," the redirect rule works as expected.

Below is my .htaccess code. My website is hosted on Cloudways.

# BEGIN WordPress<IfModule mod_rewrite.c>   RewriteEngine On   RewriteCond %{HTTP_HOST} ^example.com [NC]   RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]   RewriteCond %{HTTP:X-Forwarded-Proto} !https   RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]   RewriteBase /   RewriteRule ^index\.php$ - [L]   RewriteCond %{REQUEST_FILENAME} !-f   RewriteCond %{REQUEST_FILENAME} !-d   RewriteRule . /index.php [L]</IfModule>   # END WordPress

Viewing all articles
Browse latest Browse all 1522

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>