Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Trailing Slash from Magento URL

I understand there are many answered questions on this particular issue but I haven't found anything specific to Magento, and I was wondering if changing the .htaccess file will have repercussions in my Magento store.

Basically I have links in my navigation that go straight to a filtered category page so they look as follows..

Example.com/hairproducts.html?manufacturer=412

However when I click these links they end up navigating to the URL with a trailing slash...

Example.com/hairproducts.html?manufacturer=412/

which then ignores the filter and takes them to the category page.

Cheers for any help.

like image 355
Harry Avatar asked May 02 '14 12:05

Harry


1 Answers

I assume you have the urls generated in a phtml file like this:

<?php echo $this->getUrl('hairproducts.html?manufacturer=412'); ?>

or in a block/page content like this

 {{store url="hairproducts.html?manufacturer=412"}}

Change them to this:
In a phtml file:

<?php echo $this->getUrl('', array('_direct'=>'hairproducts.html', '_query'=>'manufacturer=412'); ?>

or in a block/page content

 {{store _direct="hairproducts.html" _query="manufacturer=412"}}

If I assumed wrong then post the way you are generating the urls.

like image 139
Marius Avatar answered Sep 21 '22 07:09

Marius