Page 1 of 1

FAQ: Troubleshooting instances of //

Posted: Tue Jan 31, 2006 11:14 pm
by Elpie
Some people have experienced problems with having links to .css and other urls showing a double forwardslash // in their code.

Look in your code for any entry that reads like this:

Code: Select all

php echo $mosConfig_live_site;?>/


Remove the / after $mosConfig_live_site;?>

$mosConfig_live_site; already includes the / into your code, so the second one is where you are getting the duplicate.

For example,
This will return the link to the css as http://adomain.com//templates/css/template_css.css
Take that duplicate forwardslash out and the problem is fixed!

Re: FAQ: Troubleshooting instances of //

Posted: Wed Feb 01, 2006 1:23 am
by de
Elpie wrote:$mosConfig_live_site; already includes the / into your code, so the second one is where you are getting the duplicate.

I am not sure I would agree with that :-)
It should actually NOT contain a slash at the end... so I'd suggest to remove it (in the configuration.php) if it is there.
(same for the absolute path)

Re: FAQ: Troubleshooting instances of //

Posted: Wed Feb 01, 2006 1:45 am
by Elpie
Try it de ;) You are correct, the setting in the configuration.php does not (or should not) contain any trailing slash.

However, please note: I am not talking here about settings in configuration, I am talking about how the code enters a trailing slash whenever the $mosConfig_live_site is called into the page.  It appends a trailing slash which makes any additional slash a duplication.

If you are in any doubt, please try it out for yourself.

Re: FAQ: Troubleshooting instances of //

Posted: Wed Feb 01, 2006 2:13 am
by de
Hmm.. by the quote in my previous post you refered to the global variable "$mosConfig_live_site" which is the value found in the configuration.php.

Say you want reference to the file "file.php" using the live site it would be:

Code: Select all

<?php
echo $mosConfig_live_site.'/file.php';
?>


I think it really depends on the script... say the script uses some kind of variable $path...

Code: Select all

<?php
$path = '/index.php';
// ... some other code
echo $mosConfig_live_site.'/'.$path;
?>


Then you get a double slash because the $path variable already contains that slash.

Another cause could be an empty variable (for whatever reason) which is assumed not to be empty... for example like this:

Code: Select all

<?php
echo $mosConfig_live_site.'/'.$option.'/file.php';
?>

If $option happen to be empty this also leads to a double slash.

In both of the last cases you may remove the slash as a quick "fix"... but you could run into other problems with the same script when $path happen to not contain that slash or $option is not empty.

After all one could also "fix" it like this:

Code: Select all

<?php
echo preg_replace('%[-:]//%', '/', $mosConfig_live_site.'/'.$option.'/file.php');
?>

(not tested though... just to give the idea).

But since you say that the following produces a double slash:

Code: Select all

<?php
echo $mosConfig_live_site.'/templates/css/template_css.css';
?>

... and you insist that the global configuration is correct... then you may have a script that is adding it? For example the one which reads the host server variable to work with different domains (e.g.: localhost vs. external access).

Sorry, it is my developers brain that had to mention it.

Re: FAQ: Troubleshooting instances of //

Posted: Thu Feb 02, 2006 5:09 am
by Elpie
Note: I am talking about the template index.php and instances of a double slash that many people are reporting.
Looking in the generated code of the site shows the instances where the // is occurring.
It is then a matter of looking in the template's index.php to see where instances occur that cause this duplication.

The example I gave is one I have come across on several sites where users have been experiencing this problem.

de is completely correct, where this problem occurs in scripts it is a technical coding issue, rather than a templating one.

(de,  let's not get into a definition of coding huh? LOL You and I would be on the same wavelength there, but I want to keep this a simple FAQ to help less experienced users ;) )