Message of the day:
Common Web Platform for the New Zealand Government, need help? Ask!
Anything related to the Common Web Platform, a CMS built on Silverstripe for government
You know when you look something up and you find only the issues to do with it? https://github.com/silverstripe/silverstripe-framework/issues/7728 (edited)
Affects 3.6.3. See also https://github.com/silverstripe/silverstripe-framework/issues/5109|#5109.
Director: alternate_base_url: '<http://mysite.test>'
This results in “Undefined index: path” here: https://github.com/silverstripe/silverstripe-framework/blob/3.6.3/control/Session.php#L358|https://github.com/silverstripe/silverstripe-framework/blob/3.6.3/control/Session.php#L358
Adding a trailing slash fixes the issue. I can’t find any documentation for
Director.alternate_base_urlwhich indicates whether or not a trailing slash should be present.
<http://mysite.test?flush>results in a redirection to the wrong URL:
This is because
BASE_URLconstant as a relative path, not an absolute URL.
BASE_URLappears to be treated like a relative path in most cases, though the <https://github.com/silverstripe/silverstripe-framework/blob/3.6.3/core/Constants.php#L11|code docs for it> suggest that it should be an absolute URL. The code to calculate
BASE_PATHif it’s not defined will also always return a directory name.
BASE_URLis used as a fallback for
Director::baseURL(), so they should be consistent. Adding a trailing slash to
BASE_URLresults in double-slashes in URLs, and removing the trailing slash from
Director.alternate_base_urlresults in issue 1 above.
To save a massive refactor to support relative/absolute urls and trailing/non-trailing slashes for both, I’m advocating mostly documentation changes and simple patches.
• Update the code docs for
BASE_URLto indicate that it should be a relative path to the document root from the domain name (with no trailing slash); • Add documentation for
Director.alternate_base_urlto indicate that a trailing slash should be present; • Bonus round: patch
Director::baseURL()to force a trailing slash
@jengeard the template uses $baseURL. So either:
So you should be able to get around this by setting an
alternate_base_url in the yml configuration files in code.