Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from superuser.com Apr 26 '12 at 14:56

This question came from our site for computer enthusiasts and power users.

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.

share|improve this answer
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 '12 at 15:41
Ah yes indeed. As with all things, there are many ways to reach the same goal :) – David Yell Apr 26 '12 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. – w3dk May 3 at 20:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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