Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

add comment

1 Answer 1

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
1  
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 :) –  DavidYell Apr 26 '12 at 16:24
add comment

Your Answer

 
discard

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.