The URL Base Prepending Culprit has been Found
Posted by Hans de Ruiter
Previously I noticed that the CMS was sometimes prepending additional directories to the URL in links, but was at a loss to explain why. My solution at the time was to add more rewrite rules to the .htaccess file. However, today I noticed that the problem was still there, this time with the blog pages.
The solution has finally been found. I had previously used a workaround in order to solve issues with the CMS' administration pages. The web-server was not returning the expected value for the following line of code:
baseURL = dirname(dirname($_SERVER['SCRIPT_NAME']));
Well, a similar line appears in sapphire/core/control/Director.php, at line 335:
$base = dirname(dirname($_SERVER['SCRIPT_NAME']));
If this code operates incorrectly in one place, it will perform incorrectly everywhere. In this new case, the solution is to add the following line to mysite/_config.php:
Director::setBaseURL('/');
With this change the problem disappears. Some of the rewrite rules in the .htaccess file might possibly be redundant now. However, it is too late in the evening for further experimentation. I will try this some other time, and publish a full set of modifications in order to get Silverstripe running on hosts such as kiwihosting.net.nz.
Blog » The URL Base Prepending Culprit has been Found
Post your comment
Comments
No one has commented on this page yet.
RSS feed for comments on this page | RSS feed for all comments
Blog » The URL Base Prepending Culprit has been Found