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.

General Questions /

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

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

Hiding a site that's in development


Go to End


5 Posts   2070 Views

Avatar
WebInt

Community Member, 14 Posts

22 April 2011 at 3:20am

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.

Avatar
swaiba

Forum Moderator, 1899 Posts

22 April 2011 at 4:58am

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

Avatar
Willr

Forum Moderator, 5523 Posts

22 April 2011 at 5:26pm

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

Avatar
WebInt

Community Member, 14 Posts

23 April 2011 at 1:02am

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.

Avatar
martimiz

Forum Moderator, 1391 Posts

25 April 2011 at 10:14pm

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