Question: So I have a page `singleTicket.php` that is grabbing an `id` from the db and passing it in the query string as `singleTicket.php?id=someIDnumber` .. Then that grabs the ticket id from the database and loads the necessary information. Easy enough. I have it redirecting if a user edits the query string id number and no id exists with the id the user put in the browser bar... but if the user takes out the query string entirely and just leaves it as `singleTicket.php` then it just has a page with a bunch of warnings on it. How can I prevent this? 

**VIDEOCAST:** <http://screencast.com/t/YFCZVsFwyui>

**Note:** 301 redirect in my .htaccess isn't working.

Answer: 
You can check if $\_GET['id'] is set:

```
if (!isset($_GET['id'])) {
    // redirect or print a message.
}

```
Check if `$_GET['id']` is set, if not redirect to wherever you want. Put this to the top of your script, before any output is made:

```
isset($_GET['id']) && !empty($_GET['id']) ? $id = $_GET['id'] : header('Location // your redirect location');

```

As a nice side effect, you'll also can set `$id` which you would most probably do either way. 

If you want to, you can redirect to 404 with

```
header("HTTP/1.0 404 Not Found");

```