i wish to rewrite a guide for my items.
i wish to make use of the id and title within the url separated with a dash such as this:
123-title means product id = 123 and title = title
so during my php i'm able to obtain the $_GET[id] after which query my database by using this id such as this:
$sql = "SELECT * from Products Where productid = " . $_GET[id];
this is what i've:
RewriteEngine On RewriteRule ^products/([0-9+])\-([a-z]+)/?$ products.php?id=$2 [NC,L]
however when i put this as url, i recieve a 404
First: you've got a syntax error.
([0-9+]) will search for
123+asd. To repair this you need to slowly move the + sign prior to the
Second: You're using $2 inside your item the product title. If you wish to make use of the ID, make use of
Here's what you ought to use:
RewriteEngine On RewriteRule ^products/([0-9]+)\-([a-z0-9_\-]+)/?$ products.php?product_id=$1 [NC,L,QSA]
I put in the merchandise amounts, dash and underscore just in case you really need it at some point.
I believe you need to use items.php?id=$1 since the first argument matched up may be the product id.