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

Hiding a site that's in development


Reply


5 Posts   1261 Views

Avatar
WebInt

Community Member, 11 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, 1798 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, 5513 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, 11 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, 1098 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...