Question

Trying to mod rewrite (.htaccess):

http://domain.com/show.php?id=2 to http://domain.com/show/id/2 by use: RewriteRule show/id/(.*)$ show.php?id=$1

and redirect user to error page if ( row[id] ) not exist in db, for now they see empty page without Value.

Thanks

Was it helpful?

Solution

You could use for example something like this:

RewriteRule ^(.*)/ show.php?id=$1

and:

$id = $_GET["id"];

.....mysql..

if (!$page_not_found) {
   header('This is not the page you are looking for', true, 404);
   include('your_404_page.php');
   exit();
}

OTHER TIPS

mod_rewrite cannot check your database. You should check for an existing entry in php and redirect from there (or show an error message directly).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top