akurjata
akurjata

Reputation: 13

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?

Upvotes: 0

Views: 624

Answers (2)

Mohammed Elhag
Mohammed Elhag

Reputation: 4302

Try this :

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

Note: clear browser cache then test it.

Upvotes: 0

Trevor J
Trevor J

Reputation: 11

Using a plugin such as WordPress Force HTTPS worked for me in a similar situation.

Upvotes: 1

Related Questions