double slash in url //

Hi , fresh instal with austere theme and appear in different block double slash in the url



all url have // in block my acount and site news block



in checkout page

in a advanced filter

in advanced search



this probleme don’t appear in another fresh install in another domain with standard skin

2.0.3



any idea?

It’s a stupid bug that cscart guys should’ve fix before the release.



Here’s the fix:



directory: core

file: fn.common.php

function: fn_redirect





change:



```php if ($external_redirect == false) {



fn_set_hook(‘redirect’, $location);



$protocol_changed = (defined(‘HTTPS’) && $protocol == ‘http’) || (!defined(‘HTTPS’) && $protocol == ‘https’);



// For correct redirection, location must be absolute with path

$location = (($protocol == ‘http’) ? Registry::get(‘config.http_location’) : Registry::get(‘config.https_location’)) . ‘/’ . $location; ```





to:



```php if ($external_redirect == false) {



fn_set_hook(‘redirect’, $location);



$protocol_changed = (defined(‘HTTPS’) && $protocol == ‘http’) || (!defined(‘HTTPS’) && $protocol == ‘https’);



$location = ltrim($location, ‘/’);

// For correct redirection, location must be absolute with path

$location = (($protocol == ‘http’) ? Registry::get(‘config.http_location’) : Registry::get(‘config.https_location’)) . ‘/’ . $location;

```

HI HYKIT,

Many thanks for the tip , But no change after modify file

cache cleaned and testing with IE an FF same result double slash appear.

with rewrite or not is the same problem, and in config mod rewrite if I allow code lang in url and diseable after = all the url have the //

Another way to resolve this bug?




function fn_redirect($location, $no_delay = false, $allow_external_redirect = false)
{
$external_redirect = false;
$protocol = defined('HTTPS') ? 'https' : 'http';

// Cleanup location from & signs
$location = str_replace('&', '&', $location);

// Convert absolute link with location to relative one
if (strpos($location, ':[B][COLOR="Red"]//[/COLOR][/B]') !== false) {
if (strpos($location, Registry::get('config.http_location')) !== false) {
$location = str_replace(Registry::get('config.http_location') . '/', '', $location);
$protocol = 'http';

} elseif (strpos($location, Registry::get('config.https_location')) !== false) {
$location = str_replace(Registry::get('config.https_location') . '/', '', $location);
$protocol = 'https';

} else {
if ($allow_external_redirect == false) { // if external redirects aren't allowed, redirect to index script
$location = INDEX_SCRIPT;
} else {
$external_redirect = true;
}
}

// Convert absolute link without location to relative one
} else {
$http_path = Registry::get('config.http_path');
$https_path = Registry::get('config.https_path');

if (!empty($http_path) && substr($location, 0, strlen($http_path)) == $http_path) {
$location = substr($location, strlen($http_path) + 1);
$protocol = 'http';

} elseif (!empty($https_path) && substr($location, 0, strlen($https_path)) == $https_path) {
$location = substr($location, strlen($https_path) + 1);
$protocol = 'https';
}
}

if ($external_redirect == false) {

fn_set_hook('redirect', $location);

$protocol_changed = (defined('HTTPS') && $protocol == 'http') || (!defined('HTTPS') && $protocol == 'https');

[B][COLOR="Blue"] $location = ltrim($location, '/');[/COLOR][/B]
// For correct redirection, location must be absolute with path
$location = (($protocol == 'http') ? Registry::get('config.http_location') : Registry::get('config.https_location')) . '/' . $location;

I had a similar problem which was causing SEO addon to stop working. I removed the / (the one immediately after LOCATION} ) from the line:




within the template:

/skins/basic/customer/addons/seo/hooks/index/meta.post.tpl

wooooo work great , magic tips. many thanks

BUT

appear Error in product listing category. and another not … aleatory

Parse error: syntax error, unexpected T_IF in /path/hosting/www/core/templater_plugins/modifier.to_json.php on line 39

I am also getting the double slashes on the following:



Domain.com

Domain.com

and others in the ‘my account’ area



thanks for any suggestions

[quote name=‘Wellsy69’]I had a similar problem which was causing SEO addon to stop working. I removed the / (the one immediately after LOCATION} ) from the line:




within the template:

/skins/basic/customer/addons/seo/hooks/index/meta.post.tpl[/QUOTE]
i tried this also but without success so set it back to default.

the double slash in some URLs works but bugs me...any suggestions on how to fix this would be appreciated,

I’ve tried a variety of ways including modifying the base href in the template:



/skins/basic/customer/addons/seo/hooks/index/meta.post.tpl



You run into other issues with it.







My way works fine. You just need to add the line:



$location = ltrim($location, ‘/’);





Clear your cache and your templates.

Hi Hykit



Can you let me know what other issues you had when you change the base href so I can check my site please?



Many Thanks

+1 for hykit

3 test to upload , clean cache ( with shared server)

and the first bug disapear ,



Any one have correct method to clean cache properly with shared server because

&cc at the end of the url give 404



with 1.3.5 version we have button in admin to clean cache , with 2.0 nothing is not really funny for develeopper or design modification.

[quote name=‘hykit’]I’ve tried a variety of ways including modifying the base href in the template:



/skins/basic/customer/addons/seo/hooks/index/meta.post.tpl



You run into other issues with it.







My way works fine. You just need to add the line:



$location = ltrim($location, ‘/’);





Clear your cache and your templates.[/QUOTE]

Thanks I tried this, but the double slashes remain, for me it seems to be only related to ‘dispatch=’ links such as:



Domain.com

Domain.com

The only solution so far has been to hard code the domain name in place of the {$index_script} in a few files. This has worked for a few, but changing some of the other php files don’t seem to have an effect.



Does anyone know exactly where the index_script is defined, haven’t been able to find the global setting anywhere including the database


replace
{$index_script}
with
http://www.domain.com/index.php

/public_html/skins/austere/customer/top.tpl
/public_html/skins/austere/customer/common_templates/search.tpl




Thank you for your suggestions.

Has this problem been solved in cs-cart 2.0.4? I prefer an official fix. Thanks in advance.

I have a fresh 2.0.4 install and having the same problem, this started as soon as I activated the SEO addon.



The categories and products are fine, but everything with index?dispatch= comes up with a double slash after the domain name, such as:



Domain.com



Any suggestions appreciated.