How to setup 301 redirects for multiple query string URLs?

I have multiple URLs that follow the same pattern like this:

https://example.com/hashtag?tag=[$string]

Is there a way to perform a 301 redirect to the following URL instead?

https://example.com/tags/[$string]

If I use this plugin, Safe Redirect Manager, is there a way to set that up?

My Server:

  • VPS CenterOS
  • NGINX

2 Answers
2

From doing some research, I’d recommend trying out this plugin: Redirection. This plugin allows you to manage 301 redirections.

I played around with the settings and they allows regular expressions which could do the following:

http://some.site/hashtag?tag=some-tag/ to http://some.site/tags/some-tag/

They provide documentation on how to set it up which can be found here. This is what I’ve done when creating the rule, try this:

enter image description here

  • Source URL: /hashtag?tag=(.*)/
  • Target URL: /tags/(.*)

I was testing this out on a local copy of WordPress and I don’t have anything right now that gives me those URL structures. Let me know if that works for you on your end. Again, you can play around with the regular expressions to get it right.

Leave a Comment