I am using the following permalinks structure: /%postname%/ and I also have some multi-page posts that look like /%postname%/2.

The problem is I see a lot of 404 errors in webmaster tools for urls like /post-name/random stuff here

How can I redirect all wrong URLs to the correct ones ?

migrated from stackoverflow.com Jun 25 '11 at 10:11

This question came from our site for professional and enthusiast programmers.


Have you tried the Smart 404 plugin? http://wordpress.org/extend/plugins/smart-404/


I don't have a webserver to test this with, but the following should work:

In your wordpress theme, you can create a 404.php file, which will be used when a 404 response is triggered. Inside this file, you could check the HTTP_REFERRER header entry - if it follows the format /post-name/[nonsensical stuff], you could then redirect the browser to /post-name/. Or simply provide a link with a message saying "couldn't find exactly what you requested, but we think this might be it".

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.