Redirect website from http to https and www

Below technique will help your website to redirect from http to https and www. Add The following code in .htaccess file to redirect website.

Redirect website from http to https and www

Start From Here ( 5 MINS READ TIME )

Add The below provided code in .htaccess file to redirect website  from http to https and www .  Also you can say that redirect website from NON- SSL website to SSL Website.

Example if your website is opening  like this :

"http://yourwebsite.com"  

& you want to URL from non secure website to secure website (http to https) then add below code in your site's root .htaccess file:


	RewriteCond %{HTTPS} off
	RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
	
	RewriteCond %{HTTP_HOST} !^www\. [NC]
	RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

After adding your website will look like: (example)

"https://www.yourwebsite.com

Note: First two lines use for redirect to https. And the second two lines will redirect to www. We recommend you to use complete code without any changing.

Note: Backup your current .htaccess file and then add these rules.

What's Your Reaction?

like
0
dislike
3
love
0
funny
1
angry
0
sad
0
wow
1