Page 1 of 1

How to achieve automatic transfer from http to https

Posted: Sun Mar 18, 2018 12:06 am
by Zhong87916
Hello, everyone. Very lucky to be here, I would like to ask a question.

I want to install an SSL certificate on my website. Hopefully, after the installation, every web page in the website can be browsed in this way: If I visit http: // URl, it will automatically jump to https: // URl.

I do not know which company's SSL is better. If you can help recommend one, I will be very grateful.


Another question:

In the server's root directory of my website, I have stored a file.htaccess.

content:
-----------------------------------------------

RewriteEngine On

RewriteCond% {SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.weldedmeshfence.com/$1 [R,L]
-------------------------------------------------- ------------------------------------------------

I found it won't work. Can anyone here help me correct it.

My website is http://www.weldedmeshfence.com.

Thank you very much.

Re: How to achieve automatic transfer from http to https

Posted: Sat Mar 24, 2018 12:59 am
by thinsoldier
It seems your SSL isn't set up correctly.

Once it is set up correctly, if your .htaccess file isn't working, make sure you vhost definition allows .htaccess files to operate.

Re: How to achieve automatic transfer from http to https

Posted: Mon Apr 02, 2018 6:39 pm
by protopatterns
Zhong87916 wrote:after the installation, every web page in the website can be browsed in this way: If I visit http: // URl, it will automatically jump to https: // URl.
Hi Zhong87916,

After you get your SSL resolved correctly, try this:

Code: Select all

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
If your server has the rewrite engine installed (almost all servers do), this makes all of your 'http://' rewrite to 'https://', without redirecting to your homepage.