Canonical URL and relative path

  • Posts: 100
  • Thank you received: 1
11 years 1 month ago #164795

-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3.1
-- PHP version -- : 5x

HI

I have a development website with live url set to : $live_site = ' www.roarpilates.com.au/dev_j3/ ;'

I have set a product with a canonical url to be "community-pilates-classes/find-a-class/product/233-corebasicspaddy.html" (without quotes)

When I select the product, the "dev_j3" is removed?

Should it not append the canonical url to www.roarpilates.com.au/dev_j3/community-...corebasicspaddy.html , as I have specified a relative url without the starting "/".

Thanks

Patrick

Last edit: 11 years 1 month ago by paddyrolls.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 1 month ago #164823

Hi,

Thanks for the report, we corrected it on our end.
First of all, thanks to edit the $live_site value to have

www.roarpilates.com.au/dev_j3/

Then thanks to edit the file "administrator/components/com_hikashop/helpers/helper.php" and replace the function "hikashop_cleanUrl()" by:
function hikashop_cleanURL($url, $forceInternURL=false){
	$parsedURL = parse_url($url);
	$parsedCurrent = parse_url(JURI::base());

	if($forceInternURL==false){
		if(isset($parsedURL['scheme'])){
			return $url;
		}
	}
	if(preg_match('#https?://#',$url)){
		return $url;
	}
	if(preg_match('#www.#',$url)){
		return $parsedCurrent['scheme'].'://'.$url;
	}
	if($parsedURL['path'][0]!='/'){
		$parsedURL['path']='/'.$parsedURL['path'];
	}
	if(!isset($parsedURL['query']))
		$endUrl = $parsedURL['path'];
	else
		$endUrl = $parsedURL['path'].'?'.$parsedURL['query'];

	if(!empty($parsedCurrent['port']) && $parsedCurrent['port']!= 80){
		$endUrl = ':'.$parsedCurrent['port'].$endUrl;
	}

	if(preg_match('#.*/#',$parsedCurrent['path'])){
		$parsedCurrent['path'] = preg_replace('#/$#','',$parsedCurrent['path']);
	}

	$cleanUrl = $parsedCurrent['scheme'].'://'.$parsedCurrent['host'].$parsedCurrent['path'].$endUrl;
	return $cleanUrl;
}

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 1
11 years 1 month ago #164910

HI Xavier

Great that works.

Thanks for the response.

Patrick

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 1
11 years 1 month ago #166286

HI

I thought this was solved but I came across another issue.

In hikashop configuration, I have set under SEF url options Force canonical URLs on listings to "Use canonical URL and generate if it is missing"

I have set the $live_site = ' www.roarpilates.com.au/dev_j3/ '

However, when the canonical urls are automatically generate it puts in "/dev_j3/community-pilates-classes/find-a-community-class/product/233-corebasics.html"

This means when the product is accessed, the following happens:

www.roarpilates.com.au/ dev_j3/dev_j3/community-pilates-classes/find-a-community-class/product/233-corebasics.html

Should it not automatically just add the "community-pilates-classes/find-a-community-class/product/233-corebasics.html" because "dev_j3" is inclued in $live_site.

Thanks

Patrick

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 2 weeks ago #168986

Hi,

Could you try to add:

	if(preg_match('#'.$parsedCurrent['path'].'#',$endUrl)){
		$parsedCurrent['path'] = '';
	}
Just before:
	$cleanUrl = $parsedCurrent['scheme'].'://'.$parsedCurrent['host'].$parsedCurrent['path'].$endUrl;

Last edit: 11 years 2 weeks ago by Xavier.

Please Log in or Create an account to join the conversation.

  • Posts: 100
  • Thank you received: 1
11 years 1 week ago #169486

Hi Xavier

Unfortunately that did not work.

Just to be clear I am refering to the Canonical URL that is generated in the product setup when I have enabled "Use canonical URL and generate if it is missing" in hikashop configuration





Thanks

Patrick

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 1 week ago #169573

Hi,

In your case, could you edit the "hikashop_completeLink()" function to:

function hikashop_completeLink($link,$popup = false,$redirect = false, $js = false){
	if($popup) $link .= '&tmpl=component';
	$ret = JRoute::_('index.php?option='.HIKASHOP_COMPONENT.'&ctrl='.$link,!$redirect);
$ret = str_replace('dev_j3/dev_j3','dev_j3';$ret);
	if($js) return str_replace('&', '&', $ret);
	return $ret;
}

It's a temporary fix, I will try to reproduce the full problem on my end in order to find the best solution to fix it.

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum