Welcome to WebmasterWorld Guest from 54.158.28.10

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

rewrite domain name to file

     
7:34 pm on Dec 7, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2002
posts:450
votes: 0


Has anyone encountered this problem? You want domain A, B,C to be redirected/rewritten externally to the same site without going into an infinite loop. You want an external redirect so that all these domains are redirected to the fully qualified domain (e.g. www.xyz.com). The problem is that since it is redirected to the same location as your .htaccess file it goes into an infinite loop. Is there a solution besides using subdirectories?
7:44 pm on Dec 7, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


Using mod_rewrite you could do this:

RewriteCond %{HTTP_HOST} !www.xyz.com 
RewriteRule (.*) [xyz.com...] [R=301]

Andreas

8:25 pm on Dec 7, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2002
posts:450
votes: 0


thanks, unfortunately this does not work on my server.

I used:
RewriteCond %{HTTP_HOST}!www.abc.com
RewriteRule (.*) [xyz.com...] [R=301,L]

and the domain name abc.com still shows up in the address bar instead of xyz.com, both abc.com and xyz.com are in the same DNS and forward to the same root of the server (RewriteBase /)...it's aggrevating!

8:34 pm on Dec 7, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2002
posts:450
votes: 0


actually, it seems to be working partially, but what gets returned is a blank HTML file that looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

This is not the index file of the site....

8:35 pm on Dec 7, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 22, 2002
posts:1782
votes: 0


The logic is this: If host is xyz do nothing since we want xyz. If host is not xyz rewrite to xyz. This is what my ruleset does.

Now here is what you are telling Apache to do: If host is not abc then rewrite to xyz, if host is abc do nothing. Given the host abc the rewritecond will be false, no rewriting to xyz takes place and abc remains in your browser´s address bar.

Andreas