14

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.

1
  • 1
    Can you give me your code where this URL generates ? If its simple then you can use $url = rtrim($url, '/'); Commented May 2, 2014 at 12:57

1 Answer 1

33

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.

Sign up to request clarification or add additional context in comments.

3 Comments

That worked a treat, I was calling them in a block as per your second suggestion. Thanks!
@marius what if we are using block file returning controller path with some querystring values. For example return $this->getUrl('namespace/controller/filename?values=' . $value1);
<?php echo $this->getUrl('namespace/controller/filename', array('_query'=>'manufacturer=412'); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.