I’m working on one project but I need to change my page URL
from:
www.example.com/?id=56D6BY32
to:
www.example.com/helloWord
How can I do that using PHP knowing that the id is very important and I don’t want to show it on the URL.
I’m working on one project but I need to change my page URL
from:
www.example.com/?id=56D6BY32
to:
www.example.com/helloWord
How can I do that using PHP knowing that the id is very important and I don’t want to show it on the URL.
2
Answers
That you’re looking for is called url rewriting. Depending on your server setup, some configuration is required. Also you need to handle these changes in your PHP.
.htaccess rewrite "/book.php?id=1234" to "/book/1234"
https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite
https://serverfault.com/questions/955109/nginx-rewrite-based-on-part-of-url
Well it is unclear if you are using a REST application or not, but to send that kind of url you would need to use some kind of MVC and REST php application.
However another way is to store your id in a session variable.
At the top of your php script you could put
And store your ID in a session like this.
On the page you are going to you can read your id like this
However you must have session_start() at the top of every php script you want to use sessions on.
I am only guessing what setup you have though, but this is a way of sending your data without showing it in the url, and even if they pressed F12 they couldn’t see what data is being sent.