If I have URL's like:-


And it is pretty difficult to reconstruct them to something like:-


Is there any way at all that I can use URL rewrites or anything else with .htaccess or on the server to display the URL's as the domain.com/category/blue-widgets on the domain.com/category/widgets/filter/blue page?

I've looked into masking URL's but got nowhere and this has been something bugging me for almost 6 months now. Is there any way to achieve what I want to do?

FYI: This is a Magento website and the above process, I am wanting to implement for potentially hundreds of URL's.


To respond to @kkugelmann's answer:-

I couldn't get your proposed RewriteRule to make a difference at all in the .htaccess file so I started testing a few things in this .htaccess tester:-

The proposed RewriteRule didn't work in this tester:-

enter image description here

However, the following did:-

enter image description here

But adding any of these RewriteRule's into the website's .htaccess file did not rewrite the URL at all...


By the way, if I add [R=301,L] to the end of the URL rewrite rule, it does actually then rewrite the rule, but of course 301 redirects it as well which is unwanted behaviour.


I found another question with the same issue... And an accepted answer that solved the problem which seemed to be something to do with using mod_proxy and the [P] tag on the rule (if I try this, the page 404's).

1 Answer 1


You'll need mod_rewrite activated and your rewrite command should look like this:

RewriteEngine on 
RewriteRule ^category/([a-zA-Z]*)-([a-zA-Z]*)$ category/$2/filter/$1^


RewriteEngine on 
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/filter/([a-zA-Z]+)$ $1/$3-$2
  • Thanks for your answer, I've updated my question to respond to your answer... I'm wondering if you could spare 10 minutes of your time on chat to look at this further with me please? The RewriteRule in the .htaccess just doesn't want to work for some reason but I suspect you're very close with this.
    – zigojacko
    Commented May 1, 2014 at 11:03
  • Have you enabled mod_rewrite?
    – kkugelmann
    Commented May 1, 2014 at 12:30
  • The Screenshots look like you want the conversion to be vice-versa... I'll rewrite the script for you and also add a third variable for the category
    – kkugelmann
    Commented May 1, 2014 at 12:32
  • Thanks but same problem as before. The RewriteRule's are not taking affect in the .htaccess. Others are, but these ones aren't. Did you read all the above edits in the question? I'd be happy to paste the entire .htaccess contents if you can spare 10 mins of your time.
    – zigojacko
    Commented May 1, 2014 at 12:56
  • Could you paste the wohle .htaccess file to pastebin? I can take a look.
    – kkugelmann
    Commented May 1, 2014 at 14:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.