Ty Bailey Ty Bailey - 1 year ago 47
PHP Question

Redirect old ASPX URL with commas to new PHP URL

I've searched around quite a bit for this, but haven't come across my exact issue.

I recently rebuilt an old

site into WordPress, changing essentially every URL on the site. I have all the redirects in place, except there are a few URL's with commas in them that I can't seem to get to redirect.

The URLs with the commas display an Apache "Forbidden" page.

For example, I have the URL:
that I need redirected to

I'm not very good with regular expressions, let alone htaccess rules, so please forgive me if what I have tried is completely wrong.

I've tried the following rules:

Redirect 301 /resourceslearn/tools/checklists(.+)-tips(.+)-tools/whitepapers.aspx$ /whitepapers/

Redirect 301 /resourceslearn/tools/checklists([^/]+)-tips([^/]+)-tools/whitepapers.aspx$ /whitepapers/

Redirect 301 /resourceslearn/tools/checklists,-tips([^/]+)-tools/whitepapers.aspx$ /whitepapers/

Redirect 301 /resourceslearn/tools/checklists([^,/]+)-tips([^,/]+)-tools/whitepapers.aspx$ /whitepapers/

Can anyone give me some assistance on how I can detect the comma in the URL and redirect it to the proper page?

Answer Source

You can not use Regex in Redirect , try RedirectMatch instead

RedirectMatch 301 ^/resourceslearn/tools/checklists(.+)-tips(.+)-tools/whitepapers.aspx$ /whitepapers/

Reference :