简体   繁体   中英

How do I redirect ALL my protocol-relative URLs to https:// urls?

I just set up my Wordpress domain to have an SSL certificate. It's working fine within the site, but if I'm coming from anywhere outside of my own website with anything other than https:// at the beginning, I just wind up on my homepage.

For example, if I enter mysite.ca/about I am taken to mysite.ca.

I have placed this code in my. htaccess file

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

But all it seems to do is direct http or protocol-relative urls to the homepage.

(my domain is andrewkurjata.ca, if it helps)

Is there something I'm missing?

在类似的情况下,使用诸如WordPress Force HTTPS之类的插件对我有用。

Try this :

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Note: clear browser cache then test it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM