1

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

I recently rebuilt an old .aspx 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: /resourceslearn/tools/checklists,-tips,-tools/whitepapers.aspx that I need redirected to /whitepapers/

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?

Ty Bailey
  • 2,392
  • 11
  • 46
  • 79

2 Answers2

1

You can not use Regex in Redirect , try RedirectMatch instead

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

Reference :

https://httpd.apache.org/docs/current/mod/mod_alias.html

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
0

Redirect doesn't use regular expressions, just a URL-path. This means, you can take the path literally

Redirect /resourceslearn/tools/checklists,-tips,-tools/whitepapers.aspx /whitepapers/

When it works as it should, you may replace the status code with 301. Never test with R=301.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • I have tested this redirect on my system and it works properly, so there must be some other rules or redirects in your htaccess. – Olaf Dietsche Jun 24 '16 at 16:10