After installing the SSL certificate, your website is accessible via HTTP and HTTPS protocols. However, it is better to use only HTTPS, because it encrypts and secures the data of your site.
How to force HTTPS using .htaccesss
JOne of the many functions you can perform via .htaccess is redirect 301, which permanently redirects the old URL to the new one.
You can activate the function to force HTTPS to all incoming traffic by following these steps:
- 1. Go to File Manager on cPanel and open .htaccess within the public_html directory. If you can't find it, be sure to make it or discover it.
If you do not know how to do this, visit the following page:
How to enable .htaccess file visibility?
- 2. Enter the following code:
- RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] - IMPORTANT: Make sure that the RewriteEngine On line does not repeat twice. In case the line already exists, simply copy the rest of the code without it.
Conclusion
Congratulations! you have successfully edited your .htaccess file and redirected all HTTP traffic to HTTPS, a secure version of your site. Depending on the platform on which you developed the website, there may be alternative ways to enable this feature.
In one of the next posts we will show some more methods of redirection via .htaccess file.
To learn more about HTTP and HTTPS please visit the following page:
CONTACT USTags
a secure version of your site
if you can t find it
in case the line already exists
after installing the ssl certificate
how to force https using
htaccess within the public_html directory
switching from http to https
you have successfully edited your
enter the following code
htaccess is redirect 301
rewriteengine on rewritecond %{https}
visit the following page
what s the difference
how to enable
htaccess file visibility
http or https
http to https
on rewriterule ^
website bureau us
contact us
htaccess file
switching http
switching https
301,ne]
blog
conclusion
congratulations
however
htaccesss
http
https
important
switch
switching