On my website a user can navigate to one of the following URLs:

www.example.com/dir1/               #items list
www.example.com/dir1/item1/         #items' content
www.example.com/dir1/item2/row3/    #items' row content

whilst each of them is a valid URL, giving different valid results. Now let's say user navigates from another website with bad URL detecting RegEx or he tries to find some exploits or fails with typing valid URL and he gets one of the following link:

[1] www.example.com/item1/row2/
[2] www.example.com/dir1/row2/
[3] www.example.com/dir1/item2/.SomewordfrombadRegEx
[4] www.example.com/dir1/item2/row3/unsupportedLevel4/

[1] URL will definitely lead to 404 Not Found page. However, the rest have valid paths' parts in them. What should I do in this cases? Should I throw 404 error for [2], [3] and [4] URLs or just ignore invalid parts?

1 Answer 1


If a page does not exist then a 404 response is expected. This lets the user know that they have a bad link. Unless you can read the user's minds (waiting for a Google project to do this), then 404s should be used as the fallback for any url of which your site cannot make sense.

If there are third party websites with old or invalid links then you either need to contact them and have them update, or let them fail until they realize they need to update their links.

For links that you can make sense of, adding route aliases / redirects is a common way to help with the transition from old links onto new links.

For example

www.example.com/dir1/item1/ - Valid link
www.example.com/item1/ - Old link, that you should now redirect to valid link

On the redirects link you should add a 301 http status of "Moved Permanently" (or another in the 300 range) to inform the third party sites / search engines that they should update their links.

Redirects aim to help maintain the user flow by getting them to the pages to which they intend to navigate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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