Redirects with parameters not working

netlify name: barbadosbydrone

I am setting up what I believe to be fairly simple redirects, however they are not working.

The old url structure is: domain/drone-video.php?drone={id}
The new url structure is: domain/drones/{slug}

e.g. old url: https://barbadosbydrone.com/drone-video.php?drone=74
new url: https://barbadosbydrone.com/drones/birds-eye-view/

I have a series of rules in _redirects of this format:
/drone-video.php?drone=74 /drones/birds-eye-view/ 301!

When I try to access Barbados By Drone Redirects I am getting the 404 error page.

The deploy log shows that all 70 redirect rules were processed.
A test of the redirect rules in Netlify's playground always shows that all redirects are valid.
Asset optimization is turned OFF (so Pretty URLs is disabled)

Any of the rules that contain query parameters - i.e. those with drone-video.php?drone={id} - are failing.
The only rule that works is /index.php / 301!

I’ve been through the guide at [Support Guide] Making redirects work for you - troubleshooting and debugging but have not been able to resolve this issue.

Any help would be appreciated.

Hi @kathylynnward,

Could you try to remove the query string from one of the URLs and see if that redirects correctly? If it does, you’d have to use the following to capture query strings:

I actually believe that you’d have to restructure your URLs in the new website, because the rules that you have would probably not work. But, let’s try to get one thing fixed at first.

The redirect did work correctly when I removed the query string from one of the URLs.
You put me on the right track.

My rule in _redirects is now very simple:
/drone-video.php /redirects/ 301!

So all old URLs containing drone-video.php now redirect to a generic redirects page.
Since query string arguments are now automatically passed through to that generic page I end up on /redirects/?drone=74 where I use javascript to look up the correct destination URL based on the drone value and redirect accordingly.

it’s not perfect from an SEO perspective but it’s a satisfactory solution for me in this instance.

Thanks for your guidance.

1 Like

Thanks for coming back and sharing, @kathylynnward! Glad everything is working :netliconfetti: