Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Redirecting url's in Apache

How do I redirect URL in Apache



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

Inactive Member
Account Expired


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...]


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


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 1, 2002
votes: 0

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!



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members