Page 1 of 1

HTTPS redirect to HTTP

Posted: Thu Mar 12, 2009 1:53 pm
by alex.barylski
The site I am currently working on was at one time completely behind SSL.

Search engines have picked up some pages and now when you click a link the page is dead because SSL has now been disabled.

Is there a simple way I can add an directive to .htaccess to basically redirect the SSL request onto a non-SSL request.

The pages exist but cannot be accessed via HTTPS but Google has now cached the pages as HTTPS so ideally whenever someone clicks a link on Google (Yahoo, whatever) which is HTTPS they are simply redirected to the HTTP version instead.

I assume this is a simple one liner? Can you show me an exmaple please :)

Code: Select all

 
RewriteEngine On
 
#RewriteCond %{HTTP_HOST} !^www\.domain\.com$
#RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
 
php_value session.cookie_domain ".domain.com"
 
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 
I am trying to force a redirect to http://www.domain.com in case the user enters without sub-domain as well. The last bit of uncommented code doesn't work either.

Cheers,
Alex

Re: HTTPS redirect to HTTP

Posted: Thu Mar 12, 2009 2:29 pm
by pickle
An .htaccess file will only be invoked if a request for a file is received. If the user is requesting a page via https (port 443 by default), and your webserver is only listening for http (port 80 by default) connections, the two will never meet and the .htaccess file will never be invoked. You can set Apache up to listen on 443, but I don't know what needs to be done with regards to encryption, even if it is just a simple forward.