I'm creating an API via PHP. I need to let users see a particular user. For example if someone goes to mysite.com/users/2
, he must get the data about the user with id=2.
This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.css$
RewriteRule ^([-/_a-zA-Z0-9\s]*)$ index.php?url=$1 [QSA,L]
The variable $url in index.php
contains the whole url (for example users/2
)
I use something like if($url == "users"){ //code }
for routes, but what can I do with id
that can be various?