Forum Moderators: phranque

Message Too Old, No Replies

Rewrite questions - subdomains

two www. subdomains

         

riverstyx

9:21 pm on Aug 8, 2005 (gmt 0)

10+ Year Member



I have a domain ie, www.example.com
with two subdomains: www.example1.com and www.example2.com

I'm using mod-rewrite to point non-www version to the www version for the primary domain, but it's not working for the subdomains. I have .htaccess files in their root directories and have done the same for each, but nothing happens (both non and www versions are available to the browser). Any ideas?
TIA,

RS

[edited by: jatar_k at 9:23 pm (utc) on Aug. 8, 2005]
[edit reason] generalized urls [/edit]

jdMorgan

10:17 pm on Aug 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I have a domain ie, www.example.com
> with two subdomains: www.example1.com and www.example2.com

As defined, www.example1.com and www.example2.com are not subdomains of www.example.com. They are simply two additional domains.

What you may mean is that you have two additional domains hosted in subdirectories of your main account, which was originally set up to host www.example.com, but I can't be sure. However, that does not make them subdomains; a subdomain of example.com would be foo.example.com or bar.example.com, or www.foo.example.com. In fact, www.example.com is a subdomain of example.com.

Please post the code you are trying to use, and specify *where* in your directory structure you have placed that code.

Jim

riverstyx

11:58 am on Aug 9, 2005 (gmt 0)

10+ Year Member



This is the root of my primary site:
/var/www/html/

I use this in the .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^primarysite\.com
RewriteRule (.*) [primarysite.com...] [R=301,L]

Which works great. The root directories of the other two domains are:

/var/www/subsite1/
/var/www/subsite2/

I placed the same rewrite statement in each of those root htaccess files and it doesn't work. These domains are above/outside of the root of the primary site. Help appreciated...

RS

jdMorgan

12:56 am on Aug 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you put the same code in all three 'root' folders, then the hostnamr in the RewriteCond will need to be changed to match the domain for that folder.

Another thing that may stop it working is if the Options for those other domain-folders are not set up like the main domain's.

Jim

riverstyx

4:30 pm on Aug 11, 2005 (gmt 0)

10+ Year Member



Resolved -- thanks for your help. FYI, for anyone with a similar problem in the future: the Apache config file has to be modified to look for the .htaccess files in the alternate directories rather than just in the default root html directory.

RS