Can an HTTPS request be redirected to an HTTP request in Apache? If so, how?

2 Answers 2


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.

  • 2
    It 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 be RewriteCond %{HTTPS} =on [NC]
    – LazyOne
    Apr 26, 2012 at 15:41
  • Ah yes indeed. As with all things, there are many ways to reach the same goal :)
    – David Yell
    Apr 26, 2012 at 16:24
  • Just 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.
    – MrWhite
    May 3, 2016 at 20:40

To redirect HTTPS request to HTTP in Apache Server, I added code in .htaccess file. This code is working well. https://www.example.com/ is 301 Moved Permanently to http://www.example.com/ with a 200 OK response.

RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
  • This 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? Apr 27, 2018 at 10:21
  • @StephenOstermiller - nice formatting, I couldn't work out what he was trying to post :P
    – Steve
    Apr 27, 2018 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.