Should I send a 404 request, for example /photo.php?id=123, if photo No. 123 does not exist?

The script will be invoked from a URL such as example.com/photo.php?id=123or example.com/photos/123, depending on whether cute URLs are included.

If photo No. 123 does not exist, the request example.com/photos/123should return a 404 error. But what about example.com/photo.php?id=123?

+5
source share
5 answers

The relevant RFC is 2616, in particular the sections status codes , and URIs . In particular, the query string is considered part of the URI, therefore it 404is the correct answer, as it means:

Request-URI.

, , 410.

200 : " ".

+3

...?id=123, .../123 , - .

, 404 - , . 404 :

404 - @# $@# $@!

404 URL-, ...photo.php, ( , ), - - : , - .

+3

, .

photo.php?id=123 - , 123, , 404. 404 , , , - .

, , photo.php?id=123 , , 123, 200 , .

, . , HTTP , , , 404 . , , , .

TL; DR 404.

+1

, 404, :

, Request-URI. , .

, 410:

,

0

I think you should throw 404. This can easily be done using the .htaccess file,

Hope this helps,

0
source

All Articles