homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

rewrite domain name to file

 7:34 pm on Dec 7, 2002 (gmt 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)

Using mod_rewrite you could do this:

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



 8:25 pm on Dec 7, 2002 (gmt 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)

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">
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>

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


 8:35 pm on Dec 7, 2002 (gmt 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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved