WordPress Force https On The Whole Website Without A Plugin

Currently I forced the https on the whole website by going to Settings -> General and changed:
WordPress Address (URL) & Site Address (URL) from http://mywebsite.org to https://mywebsite.org and it works like a charm.

BUT if the user request a url directly over the “http” protocol the user can access it.

Read More

I want the user if try to access any page over “http” protocol to redirected or something else to the same location but on the “https” protocol.

NOTE: I don’t want to edit the .htaccess file I want to put the code specifically in the functions.php file of my active theme.

Any help will be appreciated.

Related posts

Leave a Reply

1 comment

  1. Simply put this code in .htacess file at top

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