PDA

View Full Version : Help with domain forwards (apache)


webmastadj
2008-08-23, 10:29 AM CDT
I have an issue. I am trying to redirect a domain name to another domain name using the apache config file.

I have abc123.com and I want to forward that to abc321.com. I know how to do that, the problem is forwarding EVERYTHING to that domain. For example:

abc123.com/page/information/index.html to abc321.com
abc123.com/pages.html to abc321.com


I am looking for a wild card of sorts. So that ANY time a person visits abc123.com no matter what is behind it, it forwards to the main page of the other site.

abc123.com/*.* to abc321.com

How can I do this in the apache config file? I know there is something to do with the Mod_Rewrite feature but not sure how to go about setting it up.

marcrblevins
2008-08-24, 04:17 AM CDT
So many choice, you pick from this link.
http://en.wikipedia.org/wiki/URL_redirection

Dangermouse
2008-08-24, 04:27 AM CDT
Hi
this is something i recently just done, as i was/am changing domains, basically i replaced the index.html with this one, (below) you will need to change it to suit yours

<html>
<head>
<meta http-equiv="refresh" content="0;url=http://www.dnmouse.org">
<title>Redirecting to www.dnmouse.org....</title>
</head>
<body>
You should be directed to www.dnmouse.org in 2 seconds if not click the link below to go there now
<br>
<a href="http://www.dnmouse.org">www.dnmouse.org</a>
</body>
</html>

briantan
2008-08-24, 07:35 AM CDT
I posted something with just Redirect but realized that was not it.

Done some research on mod_rewrite and you'll need this in httpd.conf or extra/httpd-vhosts.conf

<VirtualHost *:80>
ServerName abc123.com
....
RewriteEngine On
RewriteOptions Inherit
RewriteRule ^/(.*) http://abc321.com/ [R]
....
</VirtualHost>

You'll need mod_rewrite module which is already enabled by default in httpd package. Check for the following in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so

Refer to document here:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

Rewrite guide:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html

Advanced Rewrite guide:
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide_advanced.html