Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The problem: I cannot get my site to redirect from https to http.

OK, there are a number of solutions offered on this but none seem to be working for me. To establish a few things, I already have .htaccess working fine on this site so needing to set AllowOverride is taken out of the equation.

The most basic I have seen is to add something like:

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

...to my .htaccess file. However this does nothing at all... as if the condition is not being met. After setting that and visiting https://mysite.com I am not redirected to http://mysite.com as I would expect rather I simply get through to https://mysite.com.

What is the cause of this? My expectation would be that with the above in my .htaccess file and with .htaccess files working fine on my site, that when I visit any https url I will be redirected to it's http equivalent.


More info

On Staging Server On my staging server adding the above to htaccess sends me to a url with a parameter appended to it like http://mystaging-site.com/?ysid=2pnd073423ra966tihf22rfr9a2

On Prod Server A quickie test on production results in an apache error page that says the page has been moved and there ws a 500 server error.

The specific of the error message are:

Found

The document has moved here. <--- this link simply points to the same page I am already on

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Here is the existing htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

And the following fails:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTPS} =on  //(with or without the equals symbol this fails)
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{HTTP_HOST} !^www.mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Close, but not quite, try:

RewriteEngine On
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
share|improve this answer
1  
That doesn't change anything (and I think the equals symbols isn't strictly required... regardless, it has the same behavior as what I tried in that it does not work in the same way) –  Lothar_Grimpsenbacher Feb 21 '13 at 0:05
    
Try that edit. FWIW, my rule is very similar (I use SERVER_NAME rather then HTTP_HOST) and this works just fine. –  kormoc Feb 21 '13 at 0:15
1  
That's the ticket! Thanks so much, kormoc. –  Lothar_Grimpsenbacher Feb 21 '13 at 0:17
    
Sweet. Glad to have helped :) –  kormoc Feb 21 '13 at 0:18
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.