How to redirect or force websites from HTTP to HTTPS via .htaccessHow to redirect or force websites from HTTP to HTTPS via .htaccess. This guide is your blueprint to redirecting your website from the normal HTTP header to the more secured HTTPS. It must be noted that for HTTPS to work on your website, you must purchase and install an SSL certificate on your server. SSL requires paid subscription to leading security
certificate providers such as Comodo and Symantec. One good free alternative is to acquire a free SSL certificate from Lets Encrypt. However, this entails that you have at least SSH access or that your hosting provider allows installation of SSL via the CPanel. Finally, this guide requires intermediate know-how on the intricacies of the .htaccess files.How to redirect or force websites from HTTP to HTTPS via .htaccess

How to redirect or force websites from HTTP to HTTPS via .htaccess

➤ How to redirect or force websites from HTTP to HTTPS via .htaccess and phpMyAdmin
To begin, use Notepad or your favorite Text Editor (Notepad++, Vim or Brackets), then paste the code below into your .htaccess file. Remember to create a backup before proceeding.
Try the following:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Also, you can redirect based on port number, for example:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Note: You can opt to replace https://%{SERVER_NAME}%{REQUEST_URI} with your sample domain name e.g. https://www.sample.com/$1, as long as you include this line RewriteCond %{HTTP_HOST} ^sample\.com [NC] below the code RewriteEngine On. Also, you can retain ^.* in the rewrite code or use ^(.*) instead. Using these instead of the rewrite code above, will give us this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sample\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.sample.com/$1 [R,L]
For SEO purposes, you may use [R=301, L] instead of [R,L]. The latter code, [R,L], tells search engines that the authority of the content must remain on the originating domain (http://sample.com for example). This is known as a temporary or a 302 redirect. If you wish to move the SEO content authority to the new domain which for this purpose is https://www.sample.com, then use [R=301,L]. This is better known as a permanent or a 301 Redirect. To implement a 301, look at the code below:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sample\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^.*$ https://www.sample.com/$1 [R=301,L]
You may also apply the rewrite code only to a specific folder:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} subfolder
RewriteRule ^(.*)$ https://www.sample.com/subfolder/$1 [R,L]
Change ‘subfolder’ to your custom folder or directory name.
Let me know if this .htaccess stuff works for you. Remember to create a backup. Please post your comments or suggestions below.
posted May 9, 2018 by THE11thROCK for TeraBlitz.com
FAIR USE DISCLAIMER: The following data is for educational, scholarship review and archiving purposes only. By viewing this information, you release the website and its authors from any responsibility or liabilities. Though we verify and maintain the accuracy of the provided data, the absence of unintented typographical and factual errors cannot be guaranteed. Use the page at your own risk. For any suggestions, updates, credits or correction requests, Contact Us: terablitz.rock@gmail.com

TeraBlitz Steam Header Custom Grid Gloss Pack Download

Related Posts

Hot Topics

 up