Jump to:

23355 Posts in 17691 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Multiple sites, same files?

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

Page: 1
Go to End
Author Topic: 1143 Views
  • mrbrdo
    Avatar
    Community Member
    5 Posts

    Multiple sites, same files? Link to this post

    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

  • Fuzz10
    Avatar
    Community Member
    787 Posts
  • mrbrdo
    Avatar
    Community Member
    5 Posts

    Re: Multiple sites, same files? Link to this post

    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...

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Multiple sites, same files? Link to this post

    Hmmmm....

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

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

  • mrbrdo
    Avatar
    Community Member
    5 Posts

    Re: Multiple sites, same files? Link to this post

    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.

  • mrbrdo
    Avatar
    Community Member
    5 Posts

    Re: Multiple sites, same files? Link to this post

    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 ^^

    1143 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.