Ok this maybe sound like the worst question on stackoverflow but here it is.
In a folder offers I have those files:
product.php
category.php
To display a product I type domain.com/offers/product.php?id=1 and
to display a category, I type domain.com/offers/category.php?id=1
Because this url looks ugly I rewrite for example the product.php using .htaccess
RewriteEngine On
RewriteRule ^([a-z0-9]+)?$ product.php?id=$1 [NC,L]
and this gives me a domain.com/offers/1
Because product.php and category.php are in the same folder and both gets a numeric variable, that means it will not execute correctly.
So a possible way is to have a slug for category.php and keep the id for product.php and then write some code for it.
My question is, is this the only way ?
Update
I didn’t tried it but what if I have the one as product.php?pid=1 and the other category.php?cid=1 ?
You will need to differentiate them in the URL. This scheme would make the URLs into:
Done via:
The first group
(product|category)captures the destination script, which is translated to$1.php. The second group is translated to to the associated id.Update
You don’t have to have them appear as separate directories
/products, /categoriesbut you do have to have some way of differentiating them. Instead you can place aporcat the start of the ID number:Done via:
Or you can expand them out to