Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Changing [base_url] in config file backspaces returned url, breaking things

Status Resolved
Add-on / Version Custom System Messages
Severity Critical
EE Version

Digital Pencil

Apr 24, 2012

I’m on EE1.7.2, running CSM 2.2.2.

Having installed CSM and got it working fine, mid development I modified my config file. I removed the trailing backslash from my base_url and base_path rules:

$conf['base_path'] = "${_SERVER['DOCUMENT_ROOT']}";
$conf['base_url'] = "http://${_SERVER['HTTP_HOST']}";

This breaks Custom System Messages’ “link” function. Now when I log in, log out, register or perform any other action that calls CSM the correct templated message is displayed, but the returned url (after the message if refreshed) is broken. Specifically instead of returning to

www.domain.com/some-page/
the link’s base domain is backpaced by one character to
www.domain.co/some-page/.

CSM worked again as soon as I reverted the config’s base_url and base_path settings to the trailing forward slash.

 

#1

BoldMinded (Brian)

Does the base_url have a trailing slash in it? All EE’s config paths should have a trailing slash.

#2

Digital Pencil

Not sure what your question is. 😊

The config setting that didn’t affect CSM was:

$conf['base_path'] = "${_SERVER['DOCUMENT_ROOT']}/";
$conf['base_url'] = "http://${_SERVER['HTTP_HOST']}/";

I then changed this to:

$conf['base_path'] = "${_SERVER['DOCUMENT_ROOT']}";
$conf['base_url'] = "http://${_SERVER['HTTP_HOST']}";

And then things broke, but only for CSM. A trailing backslash is otherwise added on all other links.

For what it’s worth, I’ve also got an .htaccess rule that adds a trailing slash in any case:

RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
 RewriteRule ^(.*)$ $1/ [L,R=301]
#3

Digital Pencil

Update: I found a work around.

$conf['site_url'] = $conf['base_url']."/";

Adding a trailing slash on the [site_url] config fixed CSM’s backspacing malarkey.

#4

BoldMinded (Brian)

Adding the trailing slash to site_url makes sense, its how EE works. In the internals it uses $this->EE->config->slash_item(‘site_url’) in various places to ensure it has a trailing slash. I would get in the habit of adding the trailing slash to that value either in config.php or within the control panel, same with upload paths etc.

Login to reply