0

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.

Kamil
  • 13,363
  • 24
  • 88
  • 183
adilizm
  • 5
  • 4
  • 1
    You should provide more information regarding your application and the HTTP server you intend to use. – chb Jul 06 '19 at 22:49
  • I edited your question (fixed formatting). Please put a little more effort to make your questions more readable. – Kamil Jul 07 '19 at 00:44
  • Possible duplicate of [PHP - hide url (GET) parameters](https://stackoverflow.com/questions/24459984/php-hide-url-get-parameters) – second Jul 07 '19 at 01:34

2 Answers2

1

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

abdusco
  • 9,700
  • 2
  • 27
  • 44
1

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

session_start()

And store your ID in a session like this.

$_SESSION["ID"] = "12345";

On the page you are going to you can read your id like this

echo $_SESSION["ID"];

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.

Thomas Williams
  • 1,528
  • 1
  • 18
  • 37