Reputation: 1
I need some help. Whenever I am making a PHP get request, say for name, how would I change this: http://website.com/page?name=Something
to this: http://website.com/page/Something
Thanks for your time!
Upvotes: 0
Views: 907
Reputation: 813
What you want is to be able to route requests. It depends on how your application receive requests
If you're using apache with mod_php, the routing corresponds to your filesystem (path in the request → path of the file). This is a very bad form of routing, and confuses a lot of beginners, because you have basically no power on how the requests are handled. Your best solution is to use Apache URL Rewriting, which will allow you to transform /page/something into /page?name=something so that it can be handled properly by mod_php.
If you have more control on your httpd, you should try some PHP routing libraries like https://github.com/chriso/klein.php or http://zaphpa.org/ that will give you a better control on how your requests are dispatched.
Upvotes: 0
Reputation: 16
Use htaccess
RewriteEngine on
RewriteBase /
RewriteRule page/([0-9a-zA-Z]+)/ page?name=$1
Upvotes: 1