Should a non-existing page ever return a 500 internal server error?

If you have a search page that uses get variables eg

www.example.com/search?this=something

and a user comes along and removes the end part leaving

www.example.com/search

would it not be expected to return you to a search form/page and at worst return an error 404 page? In 2 places on our newly rebuilt website if i remove the query part it returns a blank page that on investigation is a 500 internal server error!!

surely there is no reason it should ever return a 500 error? or am i missing something?

What server-side language is being used?

php/mysql

I should probably explain it is a page that has been built already by someone that isn’t me. Rather than a problem i am having with my own code.

Any errors show in PHP’s error logs?

I would expect it to do whatever it is you set it up to do in the given circumstances.
This could be covered in htaccess or your php.
So you decide what should happen, then make that happen.
Eg. in php:-

<?php
if(isset($_GET['this'])){
    // do something with this
}
else{
    // do something else instead
}

The something else is whatever you want to happen in such circumstances. It could be a header with a 404 code, or redirect to some other page, anything you want.

Do you have any .htaccess directives that act on search?this=something?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.