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

Using https on set pages only


Go to End


4 Posts   1350 Views

Avatar
Legin76

Community Member, 11 Posts

20 April 2016 at 10:48pm

I've used the code below to force pages that need to use SSL to use https. However once going to a secure page all other pages on the site / menu use https. How can I force all pages to use http and only the ones required to use https?

if(Director::isLive()) {
Director::forceSSL(array('/^members/','/^admin/', '/^Security/'));
}

Avatar
codemonkey88

Community Member, 24 Posts

28 April 2016 at 11:18pm

I'm not sure how forceSSL works, but have you tried

Director::setBaseURL('http://www.mysite.com');

Avatar
codemonkey88

Community Member, 24 Posts

28 April 2016 at 11:20pm

PS - I started out using SS 2.4 so tend to do stuff in _config.php that can probably be done in yml...

Avatar
Legin76

Community Member, 11 Posts

29 April 2016 at 9:02pm

Thanks for that but I'm afraid it didn't work.
It forced the base tag but, which is fine in http: but it broke https pages. Also it made the canonical link double up as below.
<link href="http://www.mysite.com/http://www.mysite.com/home/" rel="canonical">

If I removed <% base_tag %> from the page template then the menu disappeared on secure pages.

Really we need a forceSSL :false type statement to make all other urls not use it.