I have created an API and i get all my data with a specific url, and by 'id' like this :
'myfolder.php/1'
So now i try to get my url with a string :
myfolder.php/mystring
in a Htacess for the id i do like this :
RewriteRule ^[^/]+/(\d+)$ myfolder.php?id=$1
but i don't find the good regex for characters i have try like this :
RewriteRule ^[^/]+/([a-z]+)$ myfolder.php?string
Edit :
If i call url 'myurl.com'
, my function getProducts is called.
If i call 'myurl.com/1'
, getProduct($id) is called
But if i call 'myurl.com/string'
, $_GET is empty, and getProducts is called.
switch($request_method) {
case 'GET':
// HERE $_GET is empty if i called a string
if(!empty($_GET["id"])) {
$id= $_GET["id"];
getProduct($id);
}
else {
getProducts();
}
break;
default:
header("HTTP/1.0 405 Method Not Allowed");
break;
}