SlideShare a Scribd company logo
1 of 10
Download to read offline
How to Redirect HTTP to HTTPS
in htaccess?
Introduction:
SSL stands for “Secure Sockets Layer.”
The SSL certificate is a digital certificate necessary to
validate your website’s identity and authenticity. SSL is a
security protocol having the power to create and establish an
encrypted connection between a web server and a web
browser.
As a standard practice, SSL must be installed on your
website to safeguard and secure any sensitive data
exchanged between the two systems. With SSL installed, you
can keep cyber criminals at bay and prevent them from
reading and modifying the transferred data.
Why must I encrypt my website with an SSL certificate?
Most website owners would have this question. You must install an
SSL certificate if your site visitors are paramount to your business.
Installing an SSL certificate will let the search engines know that
your site establishes a secured connection when accessed. Hence,
they will not mistake your website for scams or phishing.
As a business owner, your company’s brand image, online
reputation, and customers’ trust depend on the authenticity of your
website.
Web browsers often show unsecured connection warnings if your
website doesn't have an SSL certificate. So it becomes extremely
important to redirect your website from (unsecured) HTTP to
(secured) HTTPS. If you also have plans to migrate your website to
HTTPS, this blog is for you.
Also Read: How To Upload Website Files and Database Using
cPanel
What is HTTPS?
Let’s begin by understanding HTTP before knowing HTTPS.
HTTP stands for Hypertext Transfer Protocol which is the base
of the World Wide Web (WWW). HTTP is an application layer
protocol that transfers information between the server and the
client machines. Unfortunately, HTTP is not a secure protocol that
can establish a safe connection between the client and the server.
So the experts developed a secured version of HTTP and named
it HTTPS - Hypertext Transfer Protocol Secure. HTTPS is the
primary protocol for exchanging information between a web browser
(client) and a website (server).
HTTPS establishes an encrypted connection which improves your
security during data transfer.
Also Read: Best Practices To Secure Your Website
Why Must I Use HTTPS on My Website?
When you see a Padlock icon followed by HTTPS in the address bar
of a web browser, it means that SSL Certificate has been installed
on the website you are accessing. It also means that the SSL
protocol will be used during the data exchange between the website
(server) and the web browser (client) accessing that website.
The following images will give you an idea:
HTTP to HTTPS redirection - The
Complete Process.
We will connect with 5 variations of redirecting HTTP to HTTPS.
During this discussion, we will consider the following 2 aspects:
 Use mydomain.com as an example.
 Use the .htaccess file in the cPanel for redirection purposes.
Also Read: How to Add a New Domain To Cpanel?
Let us first find the .htaccess file in the cPanel.
 Log in to your cPanel
 Go to Files and click on the File Manager from the group of
icons.
 You should select the option - ‘Document Root for.’ You can
either select the domain name from the available drop-down
menu OR click on the ‘Settings’ at the top right-hand side of
the page. Click on Settings if you have only 1 website.
 Now locate the .htaccess file.
 As the .htaccess file remains hidden, you must click on the
“Show Hidden Files (dotfiles)” checkbox.
 Once the .htaccess file becomes visible, right-click on it and
select Edit.
 In the next pop-up, again click on Edit.
Also Read: How to Take Backup of Emails from cPanel
Important Notes:
Before editing the code in the .htaccess file, here are a few
important points to remember.
 You must store your .htaccess file in the Root Folder OR in the
same folder where your website is present.
 In the .htaccess file, search for the phrase 'RewriteEngine
On.' If it already exists, add the following relevant code(s)
right after it. Do not repeat RewriteEngine ON.
 You must type your domain name instead of the example -
mydomain.com.
Types of Website Redirection
Before we dive deep into knowing the different variations of
migrating HTTP to HTTPS, let us first understand the types of
website redirections.
There are 2 types of redirections:
 Permanent Redirection: With Status Code 301.
 Temporary Redirection: With Status Code 302.
Search Engines and web browsers deal with each of these
redirection types differently.
Permanent Redirection: With Status Code 301.
As the name suggests, Status Code 301 directs the search engine
that the website has permanently moved to a new location. Hence,
it must consider only the new location for crawling and indexation
purposes.
Similarly, Status Code 301 will direct the web browser to cache
(store) the new URL and prioritize it over the older URL. This will
help access the webpage faster.
Temporary Redirection: With Status Code 302.
Contrary to Permanent Redirection, Status Code 302 tells the
search engine that the website has temporarily moved to a new
location. Hence, it must consider both the locations parallelly while
crawling and indexing the web pages. It also suggests that the older
URL, in any case, will stand valid.
Status Code 302 will direct the web browser to cache (store) only
the old URL. The redirection will happen every time the old URL
receives an access request. This is a time-consuming process, and
experts don’t recommend it.
The Drawback of Status Code 302:
Continuing with a 302 redirection for a longer period can
significantly impact search engine rankings.
Since both http://mydomain.com and https://mydomain.com are
indexed individually by search engines, all site requests get divided
between URLs during the HTTP to HTTPS redirection process. Hence,
we suggest Status Code 301 in major cases.
Also Read: How to upload Laravel Project on Shared
Hosting With cPanel?
.htaccess Code for migrating HTTP to
HTTPS.
Variation 1 - without WWW
Code for a non-www type of website:
Start below “RewriteEngine On”
RewriteCond %{HTTPS} off
RewriteRule
^(.*)$ HTTPS://mydomain.com%{HTTP_HOST}%{REQUEST_URI}
[L,R=301]
Variation 2 - with WWW
Code for a www type of website:
Start below “RewriteEngine On”
RewriteCond %{HTTP_HOST} !^www.mydomain.com [NC]
RewriteRule ^
HTTPS://www.mydomain.com %{HTTP_HOST}%{REQUEST_URI}
[L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^
HTTPS://mydomain.com %{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Variation 3 - Redirecting all your web traffic
Code for all web traffic redirection:
Start below “RewriteEngine On”
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ HTTPS://www.yoursite.com/$1 [R,L]
Variation 4 - Redirecting a selected Domain
Code for specific Domain (from multiple domains) redirection:
Start below “RewriteEngine On”
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ HTTPS://www.mydomain.com/$1 [R,L]
Variation 5 - Redirecting a selected Folder or a Webpage
Code for a specific Folder redirection:
Start below “RewriteEngine On”
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ HTTPS://www.mydomain.com/folder/$1
[R,L]
Also Read: What is FTP & How to Create an FTP Account In
cPanel?
Conclusion
After reading through this informative blog, you will have a fair idea
about using the .htaccess file in your cPanel to redirect your
unsecured HTTP website to a secured HTTPS.
Implementing one of the migration processes will help you establish
your website's authenticity with the search engines and develop
trust within your users when they perform sensitive data
transactions on your website.
On the whole, having the right SSL certificate installed on your
website places your brand in a better position than your competitors,
who still spend sleepless nights dealing with the issues of unsecured
websites. So go ahead and buy yourself an SSL certificate from Host
IT Smart and begin migrating to a secured HTTPS environment
today.
Source
https://www.hostitsmart.com/manage/knowledgebase/238/How-to-
Redirect-HTTP-to-HTTPS-in-htaccess.html

More Related Content

Similar to How to Redirect HTTP to HTTPS in htaccess.pdf

Technical seo tips for web developers
Technical seo tips for web developersTechnical seo tips for web developers
Technical seo tips for web developersSingsys Pte Ltd
 
Learn SEO Week 4 Slides (1).pptx
Learn SEO Week 4 Slides (1).pptxLearn SEO Week 4 Slides (1).pptx
Learn SEO Week 4 Slides (1).pptxssuser80d93f
 
Learn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptxLearn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptxfarahpervaiz2
 
Learn SEO Week 4 Slides MORNING.pptx
Learn SEO Week 4 Slides MORNING.pptxLearn SEO Week 4 Slides MORNING.pptx
Learn SEO Week 4 Slides MORNING.pptxTomcruise493298
 
Learn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptxLearn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptxfarahpervaiz2
 
Learn SEO Week 4 Slides.pptx
Learn SEO Week 4 Slides.pptxLearn SEO Week 4 Slides.pptx
Learn SEO Week 4 Slides.pptxTomcruise493298
 
Http to Https Get your WordPress website Compliant!
Http to Https Get your WordPress website Compliant!Http to Https Get your WordPress website Compliant!
Http to Https Get your WordPress website Compliant!Lynn Dye
 
Part 2 of Advanced SEO tips for Exponent CMS
Part 2 of Advanced SEO tips for Exponent CMSPart 2 of Advanced SEO tips for Exponent CMS
Part 2 of Advanced SEO tips for Exponent CMSChris Everett
 
search engine best ppt
search engine best pptsearch engine best ppt
search engine best pptpoppo10
 
How Does SSL Affect Your Search Engine Optimization
How Does SSL Affect Your Search Engine OptimizationHow Does SSL Affect Your Search Engine Optimization
How Does SSL Affect Your Search Engine OptimizationChristopher Dill
 
Wordpress Optimization Settings
Wordpress Optimization Settings Wordpress Optimization Settings
Wordpress Optimization Settings webhostingguy
 
Just Enough HTML for Fatwire
Just Enough HTML for FatwireJust Enough HTML for Fatwire
Just Enough HTML for FatwireKenneth Quandt
 
Tips to improve word press security ppt
Tips to improve word press security pptTips to improve word press security ppt
Tips to improve word press security pptCheap SSL Coupon Code
 
Topic 1introduction into wordpress cms tutorial
Topic 1introduction into wordpress cms tutorialTopic 1introduction into wordpress cms tutorial
Topic 1introduction into wordpress cms tutorialAhmed Fatoh
 
Rich Butkevic, PMP, CSM | How Corporate Website Projects Go Wrong
Rich Butkevic, PMP, CSM | How Corporate Website Projects Go WrongRich Butkevic, PMP, CSM | How Corporate Website Projects Go Wrong
Rich Butkevic, PMP, CSM | How Corporate Website Projects Go WrongRich Butkevic
 
HTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English versionHTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English versionMichal Špaček
 
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics ResultsWordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Resultsoneilldec
 

Similar to How to Redirect HTTP to HTTPS in htaccess.pdf (20)

Technical seo tips for web developers
Technical seo tips for web developersTechnical seo tips for web developers
Technical seo tips for web developers
 
Intro webapps
Intro webappsIntro webapps
Intro webapps
 
Learn SEO Week 4 Slides (1).pptx
Learn SEO Week 4 Slides (1).pptxLearn SEO Week 4 Slides (1).pptx
Learn SEO Week 4 Slides (1).pptx
 
Learn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptxLearn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptx
 
Learn SEO Week 4 Slides MORNING.pptx
Learn SEO Week 4 Slides MORNING.pptxLearn SEO Week 4 Slides MORNING.pptx
Learn SEO Week 4 Slides MORNING.pptx
 
Learn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptxLearn SEO Week 4 Slides MORNING (1).pptx
Learn SEO Week 4 Slides MORNING (1).pptx
 
Learn SEO Week 4 Slides.pptx
Learn SEO Week 4 Slides.pptxLearn SEO Week 4 Slides.pptx
Learn SEO Week 4 Slides.pptx
 
Http to Https Get your WordPress website Compliant!
Http to Https Get your WordPress website Compliant!Http to Https Get your WordPress website Compliant!
Http to Https Get your WordPress website Compliant!
 
Part 2 of Advanced SEO tips for Exponent CMS
Part 2 of Advanced SEO tips for Exponent CMSPart 2 of Advanced SEO tips for Exponent CMS
Part 2 of Advanced SEO tips for Exponent CMS
 
search engine best ppt
search engine best pptsearch engine best ppt
search engine best ppt
 
How Does SSL Affect Your Search Engine Optimization
How Does SSL Affect Your Search Engine OptimizationHow Does SSL Affect Your Search Engine Optimization
How Does SSL Affect Your Search Engine Optimization
 
Wordpress Optimization Settings
Wordpress Optimization Settings Wordpress Optimization Settings
Wordpress Optimization Settings
 
Just Enough HTML for Fatwire
Just Enough HTML for FatwireJust Enough HTML for Fatwire
Just Enough HTML for Fatwire
 
Tips to improve word press security ppt
Tips to improve word press security pptTips to improve word press security ppt
Tips to improve word press security ppt
 
Topic 1introduction into wordpress cms tutorial
Topic 1introduction into wordpress cms tutorialTopic 1introduction into wordpress cms tutorial
Topic 1introduction into wordpress cms tutorial
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
Rich Butkevic, PMP, CSM | How Corporate Website Projects Go Wrong
Rich Butkevic, PMP, CSM | How Corporate Website Projects Go WrongRich Butkevic, PMP, CSM | How Corporate Website Projects Go Wrong
Rich Butkevic, PMP, CSM | How Corporate Website Projects Go Wrong
 
HTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English versionHTTP Strict Transport Security (HSTS), English version
HTTP Strict Transport Security (HSTS), English version
 
Web architecture
Web architectureWeb architecture
Web architecture
 
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics ResultsWordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
WordPress Ann Arbor: Redirects and Robots for Accurate Analytics Results
 

Recently uploaded

GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in managementchhavia330
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfPaul Menig
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...lizamodels9
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCRsoniya singh
 
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...lizamodels9
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...lizamodels9
 
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedLean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedKaiNexus
 
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxBanana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxgeorgebrinton95
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni
 
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc.../:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...lizamodels9
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 

Recently uploaded (20)

GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in management
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Grateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdfGrateful 7 speech thanking everyone that has helped.pdf
Grateful 7 speech thanking everyone that has helped.pdf
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
 
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
 
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
 
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… AbridgedLean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
Lean: From Theory to Practice — One City’s (and Library’s) Lean Story… Abridged
 
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxBanana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.Eni 2024 1Q Results - 24.04.24 business.
Eni 2024 1Q Results - 24.04.24 business.
 
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc.../:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
/:Call Girls In Jaypee Siddharth - 5 Star Hotel New Delhi ➥9990211544 Top Esc...
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 

How to Redirect HTTP to HTTPS in htaccess.pdf

  • 1. How to Redirect HTTP to HTTPS in htaccess? Introduction: SSL stands for “Secure Sockets Layer.” The SSL certificate is a digital certificate necessary to validate your website’s identity and authenticity. SSL is a security protocol having the power to create and establish an encrypted connection between a web server and a web browser. As a standard practice, SSL must be installed on your website to safeguard and secure any sensitive data exchanged between the two systems. With SSL installed, you can keep cyber criminals at bay and prevent them from reading and modifying the transferred data. Why must I encrypt my website with an SSL certificate? Most website owners would have this question. You must install an SSL certificate if your site visitors are paramount to your business. Installing an SSL certificate will let the search engines know that your site establishes a secured connection when accessed. Hence, they will not mistake your website for scams or phishing. As a business owner, your company’s brand image, online reputation, and customers’ trust depend on the authenticity of your website. Web browsers often show unsecured connection warnings if your website doesn't have an SSL certificate. So it becomes extremely important to redirect your website from (unsecured) HTTP to (secured) HTTPS. If you also have plans to migrate your website to HTTPS, this blog is for you. Also Read: How To Upload Website Files and Database Using cPanel What is HTTPS?
  • 2. Let’s begin by understanding HTTP before knowing HTTPS. HTTP stands for Hypertext Transfer Protocol which is the base of the World Wide Web (WWW). HTTP is an application layer protocol that transfers information between the server and the client machines. Unfortunately, HTTP is not a secure protocol that can establish a safe connection between the client and the server. So the experts developed a secured version of HTTP and named it HTTPS - Hypertext Transfer Protocol Secure. HTTPS is the primary protocol for exchanging information between a web browser (client) and a website (server). HTTPS establishes an encrypted connection which improves your security during data transfer. Also Read: Best Practices To Secure Your Website Why Must I Use HTTPS on My Website? When you see a Padlock icon followed by HTTPS in the address bar of a web browser, it means that SSL Certificate has been installed on the website you are accessing. It also means that the SSL protocol will be used during the data exchange between the website (server) and the web browser (client) accessing that website. The following images will give you an idea:
  • 3. HTTP to HTTPS redirection - The Complete Process.
  • 4. We will connect with 5 variations of redirecting HTTP to HTTPS. During this discussion, we will consider the following 2 aspects:  Use mydomain.com as an example.  Use the .htaccess file in the cPanel for redirection purposes. Also Read: How to Add a New Domain To Cpanel? Let us first find the .htaccess file in the cPanel.
  • 5.  Log in to your cPanel  Go to Files and click on the File Manager from the group of icons.  You should select the option - ‘Document Root for.’ You can either select the domain name from the available drop-down menu OR click on the ‘Settings’ at the top right-hand side of the page. Click on Settings if you have only 1 website.
  • 6.  Now locate the .htaccess file.  As the .htaccess file remains hidden, you must click on the “Show Hidden Files (dotfiles)” checkbox.  Once the .htaccess file becomes visible, right-click on it and select Edit.
  • 7.  In the next pop-up, again click on Edit. Also Read: How to Take Backup of Emails from cPanel Important Notes: Before editing the code in the .htaccess file, here are a few important points to remember.  You must store your .htaccess file in the Root Folder OR in the same folder where your website is present.  In the .htaccess file, search for the phrase 'RewriteEngine On.' If it already exists, add the following relevant code(s) right after it. Do not repeat RewriteEngine ON.  You must type your domain name instead of the example - mydomain.com. Types of Website Redirection Before we dive deep into knowing the different variations of migrating HTTP to HTTPS, let us first understand the types of website redirections. There are 2 types of redirections:  Permanent Redirection: With Status Code 301.  Temporary Redirection: With Status Code 302. Search Engines and web browsers deal with each of these redirection types differently. Permanent Redirection: With Status Code 301.
  • 8. As the name suggests, Status Code 301 directs the search engine that the website has permanently moved to a new location. Hence, it must consider only the new location for crawling and indexation purposes. Similarly, Status Code 301 will direct the web browser to cache (store) the new URL and prioritize it over the older URL. This will help access the webpage faster. Temporary Redirection: With Status Code 302. Contrary to Permanent Redirection, Status Code 302 tells the search engine that the website has temporarily moved to a new location. Hence, it must consider both the locations parallelly while crawling and indexing the web pages. It also suggests that the older URL, in any case, will stand valid. Status Code 302 will direct the web browser to cache (store) only the old URL. The redirection will happen every time the old URL receives an access request. This is a time-consuming process, and experts don’t recommend it. The Drawback of Status Code 302: Continuing with a 302 redirection for a longer period can significantly impact search engine rankings. Since both http://mydomain.com and https://mydomain.com are indexed individually by search engines, all site requests get divided between URLs during the HTTP to HTTPS redirection process. Hence, we suggest Status Code 301 in major cases. Also Read: How to upload Laravel Project on Shared Hosting With cPanel? .htaccess Code for migrating HTTP to HTTPS. Variation 1 - without WWW Code for a non-www type of website: Start below “RewriteEngine On” RewriteCond %{HTTPS} off RewriteRule ^(.*)$ HTTPS://mydomain.com%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Variation 2 - with WWW Code for a www type of website:
  • 9. Start below “RewriteEngine On” RewriteCond %{HTTP_HOST} !^www.mydomain.com [NC] RewriteRule ^ HTTPS://www.mydomain.com %{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP:X-Forwarded-Proto} !HTTPS RewriteCond %{HTTPS} off RewriteRule ^ HTTPS://mydomain.com %{HTTP_HOST}%{REQUEST_URI} [L,R=301] Variation 3 - Redirecting all your web traffic Code for all web traffic redirection: Start below “RewriteEngine On” RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ HTTPS://www.yoursite.com/$1 [R,L] Variation 4 - Redirecting a selected Domain Code for specific Domain (from multiple domains) redirection: Start below “RewriteEngine On” RewriteCond %{HTTP_HOST} ^mydomain.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ HTTPS://www.mydomain.com/$1 [R,L] Variation 5 - Redirecting a selected Folder or a Webpage Code for a specific Folder redirection: Start below “RewriteEngine On” RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} folder RewriteRule ^(.*)$ HTTPS://www.mydomain.com/folder/$1 [R,L] Also Read: What is FTP & How to Create an FTP Account In cPanel? Conclusion After reading through this informative blog, you will have a fair idea about using the .htaccess file in your cPanel to redirect your unsecured HTTP website to a secured HTTPS.
  • 10. Implementing one of the migration processes will help you establish your website's authenticity with the search engines and develop trust within your users when they perform sensitive data transactions on your website. On the whole, having the right SSL certificate installed on your website places your brand in a better position than your competitors, who still spend sleepless nights dealing with the issues of unsecured websites. So go ahead and buy yourself an SSL certificate from Host IT Smart and begin migrating to a secured HTTPS environment today. Source https://www.hostitsmart.com/manage/knowledgebase/238/How-to- Redirect-HTTP-to-HTTPS-in-htaccess.html