[PLUG] URL redirect with mod_rewrite?

Josh Orchard josh at emediatedesigns.com
Mon Mar 10 18:41:02 UTC 2003


>
>
>> I would like to have Apache redirect URLs for me.  For example, when a
>> user goes to http://server1.domain.tld, I want them redirected to
>> http://server2.domain.tld.  Currently I'm accomplishing this with HTTP
>> redirects in a bunch of HTML files, but I think it'd be cleaner and
>> easier to manage if I could have one line per domain in my httpd.conf.
>>
>> Any suggestions?
>> Thanks,
>> ~M
>
> Matt,
>
> You may find the ProxyPass and ProxyPassReverse to be the easiest for
> whole domain redirects.
>
> Syntax is:
>
> ProxyPass / http://server2.domain.tld/
> ProxyPassReverse / http://server2.domain.tld/
>
> This would redirect anything from the first domain to the other.  The
> reverse will allow anything coming back from the 2nd to go back out from
> apache.  I use this with much success.  You can even use this for things
> like redirecting a particular sub directory to a completely differnet host
> or port.
>
> Another example would be:
>
> ProxyPass /mydir http://server2.domain.tld:8888/otherdir
> ProxyPassReverse /mydir http://server2.domain.tld:8888/otherdir
>
>
> These would go in your virtual directives.  That is assuming you have
> virtual directives. Or at the root otherwise.
>
> Josh

left something off.  This does use the proxy mod and you may need to
activate it.  But it is easier then writing a mod rewrite script.  Unless
you really have some need for regular expressions I wouldn't bother with
it.

Josh




More information about the PLUG mailing list