Consider that I am requesting this url for a JSON api response.
// url that user will type in the browser address bar
example.com/api/user/0001
I have 2 Options:
Option A
The redirection will be like this. But The address in the browser will be the same like before.
example.com?get1=api&get2=user&get3=0001
The
?get1=xxxxxx
and&get2=xxxxxx
and is IMPORTANT. if there is more slashes (/) in the url it will add more GET request like this&get4=xxxxx
&get5=xxxxx
and so on.
Then I will get the exact information form the $_GET['reques']
method like this!
$var_request = $_GET['get1'];
$var_type = $_GET['get2'];
$var_id = $_GET['get3'];
Option B
The redirection will be like this. But The address in the browser will be the same like before.
example.com?request=api/user/0001
Then I will get the exact information by exploding the api/user/0001
like this
// Geting request by $_GET
$request = $_GET['request'];
// Exploding by the (/)
$api = explode("/", $request);
// Getting my desired information
$var_request = $api[0];
$var_type = $api[1];
$var_id = $api[2];
Remember: The URL will be same as before. It should not look like
?get=
this. The url should be stillexample.com/api/user/0001
in the browser url bar.