0

I would like to know how to make a PhP url without the GET (?function=) part.

Such as:

main/function/42456457654

main being the main page, function being the page with the URL, and 42456457654 being a part selected from a database.

I know you could do this by doing main/function/?function=42456457654, but I'd like to make it so that it still communicates with the server to get values in a database at request.

1 Answers1

1

You need to put in rewrite rules in your web server's configuration.

Apache:

http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Nginx

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html

But basically it will rewrite the url from:

main/function/42456457654

to something like

main.php?action=function&id=42456457654

Or something like that

Hope that helps

Joseph Hamilton
  • 435
  • 2
  • 7
  • Ah ok, I saw another post on this, but I thought that it was reversed, or was something different. Thanks! –  Jan 21 '16 at 22:08
  • Could you actually provide an example please? –  Jan 21 '16 at 22:12
  • I believe the question is the opposite, how to go **from** main.php?action=function&id=42456457654 **to** main/function/42456457654 – Chris Jaquez Jan 21 '16 at 22:25
  • @ChrisJaquez The order you said is how I want to do it. –  Jan 21 '16 at 23:41