SSL redirect from HTTP to HTTPS
SSL redirect from HTTP to HTTPS
In this guide we show how to setup ssl redirection for your website. If you need a free SSL, follow this tutorial.
This setup is considered important among hostmasters as it brings security thus increases website reputation. It is a very simple step by adding some lines of code to your .htaccess
file.
With this tutorial we assume you know the location of your .htaccess
file.
For apache webservers:
You can do this by adding the following code in your .htaccess
file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]
</IfModule>
Don’t forget to replace yoursite.com
with your site URL.
If you are on NGINX
servers, you would add a redirect from HTTP
to HTTPS
server {
listen 80;
server_name yoursite.com www.yoursite.com;
return 301 https://yoursite.com$request_uri;
}
By following these steps, you can force your website to SSL redirection.
You may also purchase premium SSL certificates here
Tags
About The Author