Is it possible to rewrite URLs in this situation?

I am using a fantastic plugin called Query Multiple Taxonomies which provides a widget to “drill down” by category / tag and other custom taxonomies you may have.

The site is livetonom.com.

The widget (on the sidebar) gives URLS ending:

/?category_name=restaurants&locations=london

Is it possible to rewrite that to something like:

/restaurants/london

I tried using a rewrite rule generators but stuff like this added directly to .htaccess did not work:

    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)$ /?category_name=$1&locations=$2 [L]

I’m not even sure that adding to .htaccess directly is correct or will work – can anyone let me know if this is a non-starter or how I go about this?

1 Answer
1

I think you are on the right track with .htaccess and rewrite rules

What you might consider is a 301 redirect in your .htaccess like this

#fancy name redirect here
redirectMatch 301 ^/restaurant/london(.*)$ /?category_name=restaurants&locations=london

Basically you can then tell people to go to your own friendly URL and they get redirected to the longer one that WordPress uses.

I’d have a look at Perishable Press stupid tricks with .htaccess

As another point of reference you can use go to WordPress Admin > Settings > Permalinks and change the word Category to Restaurants — but that will mean all your ‘categories’ are now ‘restaurants’

Leave a Comment