문제

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

도움이 되었습니까?

해결책

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();
}

다른 팁

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top