[nycbug-talk] OT: Apache/mod_rewrite question

David Lawson dave at donnerjack.com
Sun Jan 28 23:21:36 EST 2007

All you want is to force all traffic through SSL?  This will do it:

<Insert generic SSL stuff here>

NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^(/?.*) https://%1 [R=301]

That'll force a 301 redirect to https.  You can refine it if need be,  
but it'll do basically what you want I think.

On Jan 28, 2007, at 10:36 PM, Kevin Reiter wrote:

> All,
> I've been trying to figure this out for a few hours now, and I can't
> quite get it working, and I *know* someone in here knows how to do  
> this...
> I'm trying to force all traffic to an Apache server (on my laptop) to
> use SSL.  The laptop is on a dynamic IP with no static domain, so I
> can't force http://machine.domain.tld to https:// 
> machine.domain.tld, and
> since the IP changes depending on where I am, I can't use that for a
> rewrite, either.
> Do any of you Apache gurus know of a way to do this using an .htaccess
> file or via a simple edit to httpd.conf?  I've been checking Google  
> for
> awhile, but everything I've come across doesn't quite do the trick.
> Kev
> _______________________________________________
> % NYC*BUG talk mailing list
> http://lists.nycbug.org/mailman/listinfo/talk
> %Be sure to check out our Jobs and NYCBUG-announce lists
> %We meet the first Wednesday of the month

More information about the talk mailing list