Canonical URL on MAMP generates incorrectly

  • Posts: 33
  • Thank you received: 0
9 years 10 months ago #213731

-- url of the page with the problem -- : http://localhost:8888/mysite/
-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.4.10
-- Browser(s) name and version -- : FireFox 40.0.3

Hi,

The Canonical URL generates incorrectly when on MAMP.

My site begins http://localhost:8888/mysite/...

but the Canonical URL generates http://localhost/mysite:8888/...

I need help with this.
Thanks,
Helen


Pretty Good Designs | prettygooddesigns.com | Hey, that's pretty good!

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

  • Posts: 84079
  • Thank you received: 13635
  • MODERATOR
9 years 10 months ago #213737

Hi,

Thank you for your feedback.
Change the code:

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

	if(isset($parsedCurrent['path']) && !preg_match('#^/?'.$parsedCurrent['path'].'#',$endUrl))
		$parsedCurrent['path'] = preg_replace('#/$#','',$parsedCurrent['path']);
	else
		$parsedCurrent['path'] = '';

	$cleanUrl = $parsedCurrent['scheme'].'://'.$parsedCurrent['host'].$parsedCurrent['path'].$endUrl;
	return $cleanUrl;
to:
	$port = '';
	if(!empty($parsedCurrent['port']) && $parsedCurrent['port']!= 80){
		$port = ':'.$parsedCurrent['port'];
	}

	if(isset($parsedCurrent['path']) && !preg_match('#^/?'.$parsedCurrent['path'].'#',$endUrl))
		$parsedCurrent['path'] = preg_replace('#/$#','',$parsedCurrent['path']);
	else
		$parsedCurrent['path'] = '';

	$cleanUrl = $parsedCurrent['scheme'].'://'.$parsedCurrent['host'].$port.$parsedCurrent['path'].$endUrl;
	return $cleanUrl;
in the file administrator/components/com_hikashop/helpers/helper.php and that should fix the problem.

The following user(s) said Thank You: helenbn

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

  • Posts: 33
  • Thank you received: 0
9 years 10 months ago #213801

Thank you for the quick fix! This works perfectly!!


Pretty Good Designs | prettygooddesigns.com | Hey, that's pretty good!

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

Time to create page: 0.061 seconds
Powered by Kunena Forum