[Cialug] HTTP forwarding/proxying-ish something

Zachary Kotlarek zach at kotlarek.com
Sun Jul 6 18:43:30 CDT 2008


On Jul 6, 2008, at 6:24 PM, Colin Burnett wrote:

> On Tue, Jul 1, 2008 at 5:43 PM, Zachary Kotlarek <zach at kotlarek.com>  
> wrote:
>>
>>       leeloo /etc/httpd/vhosts 0$ cat 09-proxy.conf
>>       <VirtualHost *:80>
>>               ProxyRequests off
>>               ServerName proxy.cynicbytrade.com
>>               ProxyPass / http://www.google.com/
>>               ProxyPassReverse / http://www.google.com/
>>       </VirtualHost>
>
> That seems to do exactly what I want.
>
> Any apache tricks to easily forward foo.com to www.foo.com?

I'd setup a vhost for foo.com and unconditionally redirect:

	<VirtualHost *:80>
		ServerName foo.com
		RewriteEngine	On
		RewriteRule	(.*) http://www.foo.com/$1 [L,R]
	</VirtualHost>

Just be sure the vhost entry for www.foo.com does not list foo.com as  
an alias.

--

You could also match a conditional direct with something like:

	rewriteCond %{HTTP_HOST} !^www\. [NC]
	RewriteRule	(.*) http://www.foo.com/$1 [L,R]

Be aware that I haven't tested that; IMHO using both vhosts and  
mod_rewrite for name-based conditionals costs more in confusion than  
it's worth in saved config lines.

	Zach
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1682 bytes
Desc: not available
Url : http://cialug.org/pipermail/cialug/attachments/20080706/ac87361b/smime.bin


More information about the Cialug mailing list