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.
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.
Simply put this code in .htacess file at top