2

I have thousand of error URL with patterns like this

 https://example.com/feeds/74750882288885xxx/comments/default

where 74750882288885xxx is a random number, I need help to set this URL to be 301 redirected to

  https://example.com/feeds/

or any URL with pattern /74750882288885xxx/comments/default returning 410 Gone.

Can someone help me with the .htaccess code?

3

Try something like the following at the top of your .htaccess file to redirect the URL:

RewriteEngine On
RewriteRule ^feeds/\d+/comments/default /feeds/ [R=301,L]

The pattern \d+ matches 1 or more digits. If the /comments/default part is not critical to make a match then it can be removed. If just matching a single digit is sufficient then change the regex to read: ^feeds/\d, which would be more efficient.

Or to serve a 410 Gone instead, change the rule to read:

RewriteRule ^feeds/\d+/comments/default - [G]
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.