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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Multiple sites, same files?


Reply


6 Posts   1201 Views

Avatar
mrbrdo

Community Member, 5 Posts

9 February 2009 at 6:25pm

Edited: 09/02/2009 6:28pm

I'd like a setup like this:
- sapphire
- jsparty
- etc...
- Sites
---- MySite
---- MySite2

And i want to make MySite be on www.mysite.com (/nothing more), and MySite2 on www.mysite2.com.
I've been testing this setup but i can't get it to work. At the moment, i've tried several things. Assume here that /x/ has the sapphire etc subdirectories.
- if i put the _config.php and other files/folders in a directory such as /x/Sites/mysite/_config.php, SilverStripe doesn't seem to even detect the site correctly (i get errors).
- if i put the site in /x/mysite and have the .htaccess not in /x/ but in /x/mysite, it seems to work at first, but all the links are wrong then (e.g. if the site is at www.domain.com/mysite/, it works when i open it, but if i click any menu item, it wants to go to www.domain.com/about-us/ for example, instead of what i'd like - www.domain.com/mysite/about-us/).

I basically want a setup where i have all the site-specific stuff seperate (either anywhere on the same server or at least in a sub-sub-directory), and they all use shared sapphire, jsparty etc. folders. And in this case the sapphire directory won't be accessible by web, since /x/Sites/MySite/ would be the root of www.mysite.com, but sapphire would be in /x/sapphire. I want something like this.

Thank you

Avatar
Fuzz10

Community Member, 787 Posts

10 February 2009 at 3:56am

See :
http://www.silverstripe.org/general-questions/show/251650

Avatar
mrbrdo

Community Member, 5 Posts

10 February 2009 at 5:59am

Edited: 10/02/2009 6:00am

Won't work, FTP only access to the host box. Need something else...
Can i atleast make this work:
- if i put the site in /x/mysite and have the .htaccess not in /x/ but in /x/mysite, it seems to work at first, but all the links are wrong then (e.g. if the site is at www.domain.com/mysite/, it works when i open it, but if i click any menu item, it wants to go to www.domain.com/about-us/ for example, instead of what i'd like - www.domain.com/mysite/about-us/).

Here the structure is like requested, only links are generated wrong...

Avatar
Fuzz10

Community Member, 787 Posts

10 February 2009 at 6:17am

Edited: 10/02/2009 6:18am

Hmmmm....

I don't think you can achieve what you want without a LOOOT of core hacking.... ;-)

.... You would need separate installs ....

Avatar
mrbrdo

Community Member, 5 Posts

10 February 2009 at 9:41am

Maybe it would be smart to add this to the 'to-do' list... I think it's an important feature, which is "almost" here, i guess only the paths need to be hacked.

I'd just like to avoid having my own "fork" here, then not being able to update because of that, so i'd rather see an official fix.

Avatar
mrbrdo

Community Member, 5 Posts

10 February 2009 at 7:33pm

Edited: 10/02/2009 7:55pm

I think I found a solution (i haven't extensively tested it yet but it seems to work), without any code changes or symlinks. I had to fix a bug in the code though, in "sapphire/core/control/Director.php", line 253 in "static function protocolAndHost()", the regex modifier is wrong. it's "/1" at the end, i don't know what was meant but i changed it to "/i".

Other than that, my solution only requires these changes:
- assume in the following that _config.php is located in http://www.domain.com/projects/test/_config.php, and sapphire is at http://www.domain.com/projects/sapphire/
- in _config.php of the site, put this line at the end before "?>":
--
Director::setBaseURL('/projects/test/');
--
- make a .htaccess file in the same folder where _config.php is (!!), and make it look something like this:
--
### SILVERSTRIPE START ###
<IfModule mod_dir.c>
DirectorySlash Off
</IfModule>

RewriteEngine On
RewriteBase /projects/test/

RewriteRule ^sapphire/(.*)$ ../sapphire/$1 [L]
RewriteRule ^cms/(.*)$ ../cms/$1 [L]
RewriteRule ^jsparty/(.*)$ ../jsparty/$1 [L]
RewriteRule ^auth_openid/(.*)$ ../auth_openid/$1 [L]

RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$

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

Now you can use the site from "http://www.domain.com/projects/test/" instead of "http://www.domain.com/projects/". It still requires that the _config.php is in a subfolder of where sapphire/jsparty/cms folders are, but now you can access it like that which has benefits.

I still hope in the future, this feature is added to have site-specific files totally seperate (in any folder).

Edit: this way, you still need to have the sapphire dir accessible from the web (and at parent dir) so not much has been done ^^