Redirect HTTPS request to HTTP in Apache
11,980
Yes it can, and you'll want to use an Apache htaccess file to rewrite the request. It will need to be configured in your VHost config if you are using one so that you can match on the port, as Apache doesn't know what https is in htaccess.
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
This should redirect anything incoming on https
to the matching page on http
Oh yes, I should mention that this will need to be in your .htaccess
file in the root of your website, or in the folder you want to redirect. You'll also need to ensure that in your httpd.conf
or vhost.conf
(depending on config) that you have AllowOverride
configured, otherwise your htaccess will not be read.
Related videos on Youtube
Author by
Santhosh S
Updated on September 18, 2022Comments
-
Santhosh S over 1 year
Can an HTTPS request be redirected to an HTTP request in Apache? If so, how?
-
LazyOne about 12 yearsIt may be better to rely on
%{HTTPS}
variable instead of specific port number .. as you can put HTTPS service on ANY port (depends on actual server condition/configuration/your requirements) -- 443 is just a default port, so you will have to edit this rule to make it work again if it is run on such non-standard port. Such alternate condition will beRewriteCond %{HTTPS} =on [NC]
-
David Yell about 12 yearsAh yes indeed. As with all things, there are many ways to reach the same goal :)
-
MrWhite almost 8 yearsJust to clarify, to avoid browser errors, you'll still need to have a valid security certificate installed for this to work, since the HTTPS handshake occurs before .htaccess gets a chance to work on it.
-
Stephen Ostermiller almost 6 yearsThis code looks identical to the code already proposed in the other answer. Did you have anything new to add or are you just confirming that it worked for you?
-
Steve almost 6 years@StephenOstermiller - nice formatting, I couldn't work out what he was trying to post :P