Forum Moderators: phranque

Message Too Old, No Replies

Detecting which domain name went to the default

         

folkbloke

11:08 pm on Oct 31, 2004 (gmt 0)

10+ Year Member



Please can you help:
I'm running an Apache based server, that is getting loads of accesses to the default domain, because DNS's are pointing at the box, but with a domain name that it doesn't host. I'd like to be able to conditionally re-direct these accesses.

Due to the GUI I can't directly mess about with the Apache config files, so I need a solution that will either pass the domain name to a program, or can be achieved from a htaccess file.

jdMorgan

12:15 am on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is an easy problem to fix.

Use mod_rewrite with a RewriteRule to redirect all page requests to the same page on the new domain. Then add a RewriteCond based on the %{HTTP_HOST} variable to do the rewrite only if the non-hosted domain name is requested.

Basically, a variant of the technique discussed here [webmasterworld.com].

See the resources cited in our charter [webmasterworld.com] for more information.

Jim

folkbloke

11:15 pm on Nov 1, 2004 (gmt 0)

10+ Year Member



Thanks for that. It put me on the right track and I've now got it working on a test server. I might risk going live tomorrow.