Welcome to WebmasterWorld Guest from 54.163.40.152

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

rewrite domain name to file

     

scorpion

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

10+ Year Member



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?

andreasfriedrich

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

WebmasterWorld Senior Member 10+ Year Member



Using mod_rewrite you could do this:

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

Andreas

scorpion

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

10+ Year Member



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!

scorpion

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

10+ Year Member



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

andreasfriedrich

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

WebmasterWorld Senior Member 10+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month