In previous versions of the plugin I was able to add Google tracking parameters to the redirects; however latest version appears to strip them out; is there any way to enable this again?
eg redirect from
now only ends up at
Hi @nfrctennant, I tested on my local installation and the redirect worked great, all query parameters remained.
Can you please test in a fresh installation or with other plugins deactivated and default theme to see if there is any conflict with other theme/plugin?
Confirmed, I am experiencing this issue as well. Safe Redirect Manager 1.9.3 on WordPress 5.4.1. Redirect rule settings are Redirect From: /test, Enable Regular Expressions unchecked, Redirect To: /blog, HTTP Status Code: 302 Found, Notes: empty. /test and /test/ redirect to /blog/. /test?utm_medium=test and /test/?utm_medium=test are 404. Check out https://preemptivelove.org/test/?utm_medium=test to try it out. (Future readers: I will eventually take this redirect down. Check out https://preemptivelove.org/test to confirm whether it’s still in place.)
@nfrctennant, here is the regex recipe I use in case you find it useful (be sure to check the Enable Regular Expressions checkbox):
(Ignore this next part if you’re familiar with regex. I’m including it in case you or future readers are not.)
^is a starting enforcer. It ensures we don’t match /something-else/from-path.
\/is the backslash character (
/) in regex.
from-pathis our path. If your path has a slash, remember to use
from\/pathto match from/path in the actual URL.
\/?is zero or one backslashes. So we’ll match both /from-path and /from-path/.
(\?\S*)?is zero or one of the group question mark and zero or more non-whitespace characters. This is the query string.
$is an ending enforcer. So we don’t match /from-path/something-else.
$1in Redirect To is the query string we matched. It’s available to us because we wrapped it in parenthesis.
I recommend testing your regex. I use https://regex101.com simply because it comes up top when I search “regex tester”, ha. When putting your URLs in the tester, be sure to remove your domain because we start our regex with
^. So put /from-path?utm_medium=test and not https://domain.com/from-path?utm_medium=test.
Hope this helps!
- This reply was modified 2 years, 5 months ago by Taylor Gorman.
@taylorgorman For your case, you can use a wildcard to achieve the same result as using regex, for example:
/test?utm_medium=testwill result in a 404 error because it isn’t matched with your redirect, adding a wildcard will help it match.
Your issue is not the same as the OP issue. As I understand, the OP issue is visiting
https://example.com/SWagm/, it should redirect to
https://example.com/contractors-agm?utm_source=SW-AGM-2020&utm_medium=Flyer, but it redirects to
https://example.com/contractors-agm/instead. Currently, I can’t reproduce the problem on my test environment.
@dinhtungdu, Hi, I am also having trouble redirecting using a simple regular expression.
Not sure if the issue is with this plugin or with the plugin that generates the URL I want to redirect from.
I am using “WooCommerce AJAX Products Filter” plugin by BeeRocket, which filters products with a drop-down selector and refreshes the shop page to have the following URL, for example:
I would like to redirect it to:
I enabled regexp and added the following redirect rule:
* HTTP Status Code: 302 Found
However, I can’t get it to redirect from:
Wondering if this should work?
BTW, I used the regexp test website provided by @taylorgorman.
It says that the the regexp and original URL match:
@dinhtungdu, thanks for your reply and code.
It helps (see below) but it’s not quite redirecting.
The URL still stays un-redirected when I select a category or subcategory from the ajax filter drop-down box. That is, it stays at /my-shop-page/?filters=product_cat[MY_CATEGORY_1]
Ideally, it should redirect because the categories and subcategories use a sidebar page template (to display certain promotional messages), whereas the shop main page uses a full page template with the filter drop-down box at the top of the page.
If there is no redirect, then filtering by categories and subcategories will stay on the full page template (no sidebar).
However, there is a slight improvement. Now, when I select a category to filter by, the subcategories of the filtered category are displayed at the top of the list of filtered products. And each of the subcategories have their own URL to redirect to.
If I can’t get the redirect to work completely after filtering, I might have to abandon the ajax filter in favour of a proper redirect method such as side bar links
Not sure if it matters but I forgot to mention:
After using the ajax dropdown to filter by category or subcategory, the URL stays on the unredirected filter URL, but when I refresh the page, it does redirect to the category page or subcategory page.
@ragrant0 It’s expected because when you select categories from the sidebar, the URL is changed by JS, it’s not an actual request, so no redirect occurs. Safe Redirect Manager only works when WP parse requests.
@dinhtungdu thanks for your reply. I understand.
FYI, I’m not selecting from the sidebar. I’m selecting from the ajax filter dropdown box positioned above the list of products on the shop page (full-page / no-sidebar template). Only the categories and subcategories pages have sidebar. That’s why I prefer to redirect to those pages.
In any case, I guess I should abandon the ajax filter and use a different method.
Thanks for your help.
And many thanks for a useful plugin. I’ve been using it for a long time for a bunch of other redirects
I want it to apply this rule for all posts:
please any idea how to make this work
- The topic ‘Adding parameters to redirect (eg utm)’ is closed to new replies.