How to redirect HTTP to HTTPS using htaccess

The below code when added to an .htaccess file will automatically redirect any traffic destined for http: to https:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  • 180 Users Found This Useful
Was this answer helpful?

Related Articles

What is the path to sendmail?

Generally, it will be at /usr/sbin/sendmail however if this does not work for you, please open a...

What is the path to public_html?

The full system path to public_html is:/home/username/public_html'username' is your cPanel username

What to do if your WordPress site is hacked

Why is my site hacked?Why is my site hacked? What should I do now?A web site is usually hacked...

What are your DNS Nameserver details?

Please refer to your Welcome email that contains your username and password that you received...

php_flag and php_value errors, and how to fix it.

Problem:You are seeing Internal Server Errors in your browser when you view your web site.You...