[nycbug-talk] OT: Apache/mod_rewrite question

Kevin Reiter tux at penguinnetwerx.net
Tue Jan 30 01:02:19 EST 2007

Dan Langille wrote:
> On 28 Jan 2007 at 23:09, Kevin Reiter wrote:
>> Kevin Reiter wrote:
>>> Jonathan Stewart wrote:
>>>> 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.
>>>> Not exactly what your asking about but have you considered using a 
>>>> dynamic DNS service?  I use No-IP () and have been very happy with 
>>>> them.  They even manually setup IPv6 records for me even though they 
>>>> are not technically supported.  Although I am paying for a domain name 
>>>> and dns they provide free sub-domains as well.  If thats not an option 
>>>> I'll see what I can do about a rewrite rule for you.
>>>> Jonathan
>>> This is for a traveling laptop that I use both at home and at client 
>>> sites, and as a test machine at my new job, so I don't always have the 
>>> same IP, which is how I typically access the server.
>>> I should've mentioned that I know about zero when it comes to writing 
>>> rewrite rules (this would be a first).
>>> In this case, a dynamic DNS service would do nothing for me (I've had a 
>>> paid account with FreeDNS[1] for years now.)
>>> Basically, I'm looking to force the use of SSL on my webserver 
>>> (apache+mod_ssl-1.3.37+2.8.28) when the IP and domain are always changing.
>>> I recall seeing something about {SERVER_ADDR} as a variable, which would 
>>> be exactly what I'm looking for, but I don't have a clue outside of that 
>>> what to write in the .htaccess file.
>> Helps when I include the link..
>> [1] http://freedns.afraid.org/
> Does this help?  This is how I redirect http://papers.bsdcan.org to 
> https://papers.bsdcan.org
> <VirtualHost>
>     ServerAdmin dan at langille.org
>     ServerName  papers.bsdcan.org
>     Redirect    permanent / https://papers.bsdcan.org/
> </VirtualHost>
> I use similar methods to redirect http://freshports.org to 
> http://www.freshports.org/
> hth

It would if I had a static IP, but since it changes multiple times a 
day, I don't think it'll fly for the laptop.  It will, however, be 
perfect for a few other machines I just setup at work - thanks, Dan!

More information about the talk mailing list