Welcome to WebmasterWorld Guest from 54.159.165.175

Forum Moderators: Ocean10000 & incrediBILL & phranque

Redirecting url's in Apache

How do I redirect URL in Apache

   
5:08 pm on Apr 2, 2003 (gmt 0)

10+ Year Member



I cannot seem to find the answer to my question anywhere. What I need to do is simply redirect an incoming url to a different one using apache.

Here is an example of what I need to do... If I'm just an idiot, feel free to let me know :)

incoming url= [dog.domain.com...]
redirect to= [domain.com...]

or

incoming url= [cat.domain.com...]
redirect to= [domain.com...]

or

incoming url= [mouse.domain.com...]
redirect to= [domain.com...]

Am I making sense? It seem from what I have read that Apache rules in redirects, rewrites and such... but being a recent convert from IIS and Domino I just don't have the skills to figure this out it seems.

Thanks to anyone that can help!

5:24 pm on Apr 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi adrenalinehigh:

Welcome to Webmasterworld!

There are a couple ways to acomplish this, and both depend on certain moidules being in your Apache build... either mod_rewrite or mod_alias. The first allows more complete rewriting, but for this, either will do...

for mod_alias, just add this to your httpd.conf on the appropriate <Container>

RedirectPermanent /URI/TO/OLD/REQUEST/ [URL...]

Note: URI vs. URL- you use BOTH, but you cannot switch one with the other. Your fisrt rewrite would be written:

RedirectPermanent / [domain.com...]

More info here: [httpd.apache.org...]

For mod_rewrite, you would do this:

ReWriteEngine ON
RewriteRule Expression New Location [CODES]

This is much more complex, but you can do a lot more with it, too. But be very careful, it can be quite powerful, and do things you may not expect.

More info here: [httpd.apache.org...]

Good Luck!

dave

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month