[KLUG Members] Rewriting to SSL

Adam Tauno Williams adam at morrison-ind.com
Tue Aug 2 11:10:47 EDT 2005


> > I want to drive all traffic on a site to use SSL.  But user's will never
> > remember to type https://...
> > I've done this in the past by simply putting -
> > <IfModule mod_rewrite.c>
> > RewriteEngine on
> > RewriteCond %{SERVER_PORT} !443$
> > RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
> > </IfModule>
> > - in the configuration.  And all was well.
> > But now I just get a "Error 400  Bad Request!" message whenever I visit
> > a http://... URL.
> > Going to https://.... works perfectly.

I got this to work.  Apparently it has to be done from within a virtual
host entry.

> I did something like that a different way.
> First I setup http and https to have different server root directories.
> The https htdocs was populated with the entire web site, and the http
> htdocs directory only contained an index.php file, which did a redirect
> to the https site:   <?PHP header("Location: https://site.com/"); ?>
> Then if someone went to http://some.site/somedir/somefile.php I set
> Apache to redirect back to index.php on non existent URL's:
>   ErrorDocument 404 /index.php
> (which in turn redirects to the https site)  Works great!  :-)



More information about the Members mailing list