Fix Double Slash Error
-
I’m not sure where to post this but some of my URLs have been broken on my wordpress blogs for a while. The reason they were broken is they had a // at the end of the url.
I finally spent some time and figured out the cause and fix for this bug.
In wp-includes/functions-formatting.php there is a function called “trailingslashit”:
function trailingslashit($string) {
if ( '/' != substr($string, -1)) {
$string .= '/';
}
return $string;
}This code should look like this:
function trailingslashit($string) {
if ( '/' != substr($string, -1,1)) {
$string .= '/';
}
return $string;
}Previously it was checking the entire string rather than the last character.
This is my first time posting here so hopefully this will come out formatted correctly ??
G-Man
- The topic ‘Fix Double Slash Error’ is closed to new replies.