如何在地址栏中隐藏GET变量


How to hide GET variable in address bar

可能的重复项:
如何从 PHP 脚本中更改 URL 的外观

我的地址栏中有这个

localhost/somedirectory/main.php?id=123456

如何隐藏这些 GET 变量,使其变为

localhost/somedirectory/main/123456

我知道.htaccess是答案,但到目前为止我的尝试无济于事。有人可以阐明如何实现它吗?

没有办法按照你想要的方式使用 PHP!

只有 htaccess 才能帮助完成此任务。

RewriteEngine on 
RewriteBase    /
RewriteRule ^localhost/([^/]*)/([^/]*)/([^/]*)$    localhost/$1/$2.php?id=$3