I am a front-end developer launching a site that is replacing an old site. I am having a hell of a time with the redirect rules for the dynamic URLs from the old site. After a couple hours of trial and error, I am posting here to see if someone can show me the missing character or error in my approach.
Old site page URL: [https://www.mysite.com/teacher-profile?name=JoeSchmoe&teacher=69])
Desired redirect URL: [https://mysite.com/directory-teachers]) (static page where they can find the teacher)
What is currently happening when I redirect “/teacher-profile?name=JoeSchmoe&teacher=69” to [https://mysite.com/directory-teachers]):
[**https://mysite.com/directory-teachers**]The dynamic string is appended to the end of the destination. This URL doesn’t exist and so 404s. How can I make the redirect work without it appending the dynamic info from the source?
Thank you for reading this far! Happy to clarify anything that isn’t clear here.
[ad_2]
Can you post the redirect rules you are using?
Hi, may I ask why are you not using e.g. 301 redirects plugin? It’s a more convenient way.
You might try the following in your functions.php and see how that does
`add_rewrite_rule(‘^directory-teachers/(.*)/(.*)?’, ‘index.php?pagename=directory-teachers&name=$matches[1]&teacher=$matches[2]’, ‘top’);`
You better ask Chat GPT humans take too long to figure this out and Chat GPT is real good at it.