How to Redirect All HTTP to HTTPS .htaccess

How to Redirect All HTTP to HTTPS .htaccess

by admin

If you have installed an SSL certificate on your website, the website may not be available via a secure HTTPS connection by default.

In this case, you need to redirect your visitors to the secured (HTTPS) version of your site. There are some way to redirect HTTP to HTTPS but we share only one way about it.

You need to insert the following lines of code in the .htaccess file.

# BEGIN Redirect HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# END Redirect HTTP to HTTPS

Related articles

Placeholder Image
CDN Font Problem

Sometimes the fonts do not work after cdn integration because some browsers refuse to embed the fonts which come from…

How to Enable Gzip Compression in WordPress
How to Enable Gzip Compression in WordPress

Used by more than half of all websites, Gzip Compression remains popular today.

Placeholder Image
Redirection to /wp-content/cache/all/index.html Problem

If there is a 301 redirection rule in htaccess, apache may redirect the url to http://yourdomain.com/wp-content/cache/all/index.html.

Ready to get started?

Purchase your first license and see why 1,500,000+ websites globally around the world trust us.