0

Basically I have a shared server with an existing site and a new site. On most shared hosting accounts(linux) I have, the file structure is something like this:

- public_html 
-- firstsite.com 
-- secondsite.com

For the server in question the structure is more like this:

- public_html 
-- all of the folders and files of the first site loose in this directory 
-- secondsite.com

So if I try to access secondsite.com from a browser, I am sent here instead: http://firstsite.com/secondsite.com

...which is obviously incorrect. My hosting support told me that if I rename the htaccess file used by firstsite.com the secondsite.com will resolve as: http://secondsite.com

I obviously just can't disable my htaccess file because that will bork the first site.

So I'm looking at my htaccess file and thinking this is the problematic line:

### Only allow access without the www. #### 
   RewriteCond %{HTTP_HOST} !^firstsite\.come$ [NC] 
   RewriteRule ^(.*)$ http://firstsite.com/$1 [R=301,L]

I'm thinking I need a similar set of rules that pertain to secondsite.com?

Any suggestions would be great.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220

2 Answers2

0

First your RewriteRule will always be executed since you have an invalid domain name in RewriteCond and it will always be different from that host (you have .come).

Second I think you could try to add this as your first set of rules in your .htaccess file:

RewriteCond %{HTTP_HOST} ^secondsite\.com$ [NC] 
RewriteRule ^(.*)$ /secondsite.com/$1 [QSA,L]
Qben
  • 2,617
  • 2
  • 24
  • 36
0

YOu need to change your rule from:

RewriteCond %{HTTP_HOST} !^firstsite\.come$ [NC] 
RewriteRule ^(.*)$ http://firstsite.com/$1 [R=301,L]

To:

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

So that when the host is secondsite.com, the rule won't try to redirect back to first site.com

Jon Lin
  • 142,182
  • 29
  • 220
  • 220