Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Hiding a site that's in development

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: 1221 Views
  • WebInt
    Avatar
    Community Member
    11 Posts

    Hiding a site that's in development Link to this post

    Hi, I'm sure someone must know this.

    I want to hide a site that's in development from search engines and users while the site is in developer mode.

    Is there a way to redirect any visitors to a given page when the environment type = dev & they aren't logged in?

    I've tried this in _config.php in /mysite/

    if (Director::isDev() & !Member::currentUserID()) {
    Director::redirect(Director::baseURL());
    }

    No worky.

    Thanks.

  • swaiba
    Avatar
    Forum Moderator
    1786 Posts

    Re: Hiding a site that's in development Link to this post

    you could put a htaccess authentication...
    http://www.htaccesstools.com/htaccess-authentication/

    but with silverstripe you could try to wrapping the contents of Page.ss with...

    <% if CurrentMember %>

    ...

    <% end_if %>

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: Hiding a site that's in development Link to this post

    We use BasicAuth::protect_entire_site(); when in test mode. This requires a username and password from your SS database to see the site.

  • WebInt
    Avatar
    Community Member
    11 Posts

    Re: Hiding a site that's in development Link to this post

    Thanks willr, that's a heavy duty way of doing it.

    Just noticed this though, setting the access level on the root of the site to logged in users only sorts my issue. Permissions inherit all the way down, also means we can set a single page access for a client to check out, and make the others inaccessible.

    Thanks swaiba, will check out the htaccess method.

  • martimiz
    Avatar
    Forum Moderator
    1068 Posts

    Re: Hiding a site that's in development Link to this post

    Nice! 'protect_entire_site' - totally new to me, wonder how I could have missed it all this time...

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