Forum Moderators: phranque

Message Too Old, No Replies

Rewriting a subdomain to a new domain

         

encyclo

1:34 am on Oct 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've got myself a bit stuck with a mod_rewrite rule that either isn't working at all, or it breaks things.

I have one site www.widgets.org stored in the directory

/home/encyclo/public_html
. In that directory, I'm doing some basic rewriting to make sure a couple of other domain names switch to www.widgets.org.

I have a subdomain off the first site, example.widgets.org. It is stored in the directory

/home/encyclo/public_html/example
. I've just bought a domain name www.example.com, which now resolves to that subdomain/directory.

What I want to do is very simple: any requests for example.widgets.org or example.com should be rewritten to www.example.com. Trouble is, if I place this:

RewriteCond %{HTTP_HOST} ^example\.com [OR]
RewriteCond %{HTTP_HOST} ^example\.widgets\.org
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

in

/home/encyclo/public_html/example
, it doesn't work, and if I place it in
/home/encyclo/public_html
, it redirects to [example.com...]

I know, it's Friday night, and it's not safe to be doing rewrites, but has anyone got a clue what I'm doing wrong?

Many thanks for your help.

jdMorgan

1:45 am on Oct 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I've just bought a domain name www.example.com, which now resolves to that subdomain/directory.

I think the key is, what do you mean by "which now resolves to that subdomain/directory"? How does it resolve to that subdirectory? You can point the new domain to your server's IP address using the new domain's DNS zone file, but how specifically does it get to its subdomain-subdirectory below document_root?

Look for conflicts there, especially if "there" is a "control panel" of some sort.

Jim

encyclo

2:45 pm on Oct 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The nameservers are set to my hosting company as usual, and the domain name is set as a ServerAlias for widgets.example.org, with the document root as
/home/encyclo/public_html/example
.

There is a bit of cruft in the public_html .htaccess file which I've cleared out, but I think I'm right in thinking that both .htaccess files are going to be parsed by the server when accessing the subdomain/new domain. Thing is, I can't seem to get it to work even if I disable the first .htaccess (unless I'm having caching problems).