Change URL from ?index to /index

232 Views Asked by At

Today we use a switch for our site to work.

switch (key($_GET)) {
  case 'index': include('assets/pages/index-page.php'); break;
  case 'faq': include('assets/pages/faq-page.php'); break;
  ...
}

That means that the URL is https://finna.nu/?index But we want it to be: https://finna.nu/page/index

How do we do that in PHP? Can we still use the switch we have?

1

There are 1 best solutions below

2
On

Sure you can do that. Use pathinfo() in the switch statement to get the extra path trailing the page name.