https to http redirect htaccess – How to redirect from HTTPS to HTTP?

https to http redirect htaccess – To redirect your website from HTTPS to HTTP, add the following rule in your website’s .htaccess file:

https to http redirect htaccess

Redirect HTTPS to HTTP

RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

To redirect from HTTPS to HTTP

home page only using the following rule.

RewriteCond %{HTTPS} on
RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301,L]

Https to http redirect using htaccess

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

1. Open .htaccess file

$ sudo vim /var/www/html/.htaccess

2. Add Rewrite Rule to .htaccess

RewriteEngine on

# force ssl
RewriteCond     %{SERVER_PORT} ^80$
RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

don’t Miss : Https To Http Redirect Using .Htaccess File

Read Also:  jQuery Print Dynamic Content using PHP MySQL Example

also redirect HTTP to HTTPS in your virtual host’s config file.

<VirtualHost *:80>
   ServerName www.domain-name.com
   Redirect permanent / https://www.domain-name.com/
</VirtualHost>

<VirtualHost _default_:443>
   ServerName www.domain-name.com
   DocumentRoot /var/www/html/domain-name
   SSLEngine On
# etc...
</VirtualHost>

and last 3. Restart Apache Server

$ sudo service apache2 restart

I hope you get an idea about https to http redirect htaccess.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.