You can do this by adding the following code in your .htaccess file:
1 2 3 4 5 |
<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 (most users are not), you would add the following to redirect from HTTP to HTTPS:
1 2 3 4 5 |
server { listen 80; server_name yoursite.com www.yoursite.com; return 301 https://yoursite.com$request_uri; } |
Leave a reply