Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

htaccess configuration for two separate sites


Go to End


2 Posts   1385 Views

Avatar
juneallison

Community Member, 110 Posts

12 October 2013 at 2:03am

Hi,

This is probably more of a general web dev question but I'm not sure how helpful my hosting support is going to be so I thought I'd ask it here.

Basically I have a shared server with an existing and a new site. On other shared hosting accounts the file structure is usually 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 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 might be the problematic line:

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

or maybe it has something to do with this section?

### SILVERSTRIPE CONT ###
RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]

Any advice on what I need to add, change, or take away, would be great.

Thank you!

Avatar
juneallison

Community Member, 110 Posts

17 October 2013 at 7:46am

To answer my own question I partially solved my problem by adding:

RewriteRule ^secondsite\.com - [L,NC]

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

Now if I go to www.secondsite.com everything looks fine. But if I try to access secondsite.com (no www) the url still resolves as:
http://firstsite.com/secondsite.com

Any suggestions would be great.

Thanks!