Hello all,

I've been building a website that requires some strict user-input to get the content the user wants. Sorry if that sounds vague, but I'll try to explain what I mean below.

domain.com/req/subreq/sub-subreq/sub-req4/

This is the structure to request something. To put the allowed characters in regex, you would get;

domain.com/[a-z]+/[a-z]+/[a-z-]+/[a-z0-9-]+/

Now I was wondering; what HTTP response to give when a user doesn't comply to use the correct syntax?
404 is for 'explaing' to the user's browser that there is no page with such title, for example;

domain.com/english/category/entertainment/yuiopasdfg/ - this will give a 404 as yuiopasdfg does not exist.

But when a user does not use the correct syntax, shouldn't the server response be e.g. 400 "The request cannot be fulfilled due to bad syntax." or 501 "The server either does not recognize the request method, or it lacks the ability to fulfill the request." Altough 501 would be a server fault.

What do you think?

Thanks in advance,
xtaste

(PS: Sorry if I'm being unclear, it's been a while since I wrote in English )