I have a page which will have a URL like this posts.php?thread_id=42&main_id=5 but of course the id's could be anything
I want a code to see if the URL is just posts.php and if it is to redirect them...
you could use
$_SERVER['QUERY_STRING'];
test and redirect off that
Or, if you mean the values for the IDs could be anything, but those IDs will be set normally to something, you could test for them:
if (! isset($_REQUEST['main_id']) && ! isset($_REQUEST['thread_id'])) { // neither one sent } else { // etc. }