-1

I'm looking for a way to turn variables in a URL after the question mark into a simple notation with a slash.

For example: I would like to make it possible to enter this link:

http://localhost/MySite/View?Name=Test

in this form into the browser

http://localhost/MySite/View/Test

The MySite then should recognize "Test" as the Name variable. So basically the two links should give the same result.

How it will be done ?

MS Dhoni
  • 7
  • 1

1 Answers1

0

You should read your request uri and search for the third subdirectory:

$view = $_GET['Name'];
if(!isset($view) && isset($_SERVER["REQUEST_URI"])) {
    $uriArray = explode($_SERVER["REQUEST_URI"]);
    if(count($uriArray) == 3 && $uriArray[1] == 'View') {
        $view = $uriArray[2];
    }
}
maestroosram
  • 196
  • 12