Ben
Ben

Reputation: 2564

htaccess rewrite url rule trouble detect $_GET isset

RewriteEngine On
RewriteRule ^about/([^/.]+)/?$ about.php?id=$1 [L,QSA]

I have a page use htaccess rewrite rule for url

/about/33

the page require $_GET['id'] to fetch db

however i have trouble to detect GET variable isset

if(isset($_GET['id'])){fetch data...}else{header("location:...");}

if user only enter /about/ without $GET['id'] the page will not found instead run header("location");

is anyway to solve this?

Upvotes: 2

Views: 677

Answers (1)

dap.tci
dap.tci

Reputation: 2485

try this:

RewriteRule ^about/([^/.]*)/?$ about.php?id=$1 [L,QSA]

Put * instead of +

Upvotes: 3

Related Questions