htaccess Redirect Method non-www to www and HTTP to HTTPS


htaccess Redirect Method non-www to www and HTTP to HTTPS

htaccess Redirect Method

This is My Second Tutorial Related to htaccess in previous Tutorial we see about htaccess Method to Remove a .php and .html extensions.htaccess File are Very Important because it controls Our website Outside Mechanism Process like Page redirection, Directory redirection in previous tutorial I explain about the htaccess File Working.ok let’s come to our topic.

htaccess Method Redirect non-www to www

Google Recommends www URLs yes as per Search Engine NOn-www and www are Different.If we use Both non-www and www means search Engine treated as duplicate contents.you can use htaccess Method Redirect non-www to www.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mywebsite.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [L,R=301,NC]

 

htaccess Directory Redirection

RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com$
RewriteRule ^folder\/?$ "http\:\/\/www\.myebsite\.com\/" [R=301,L]

 

htaccess Method Redirect HTTP to HTTPS

https Means Secure Hypertext Transfer Protocol.which was used to secure our user’s Information, Data’s and Payment Gateway’s.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

Force http to https Redirection

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.mysite.com/folder/$1 [R,L]

From the Editor’s Desk

Don’t forget to replace mysite.com with your website’s domain name.

If you Have Any Doubts Feel free to comment here i will help you.

Updated Post for HTTPS Version – Proper Method to redirect our visitors to HTTPS version via htaccess File

Also Read


Was this article helpful?
Thanks!

Your feedback helps us improve Allwebtuts.com



3 Shares
+11
Tweet
Share1
Pin1
Stumble