【问题标题】:How to hide GET variable in address bar [duplicate]如何在地址栏中隐藏GET变量[重复]
【发布时间】:2012-06-21 06:07:47
【问题描述】:

可能重复:
How to change appearance of URL from within a PHP script

我的地址栏中有这个

localhost/somedirectory/main.php?id=123456

如何隐藏那些GET变量,所以变成了

localhost/somedirectory/main/123456

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

【问题讨论】:

  • 您可以发布一些您尝试过的代码吗?那里有大量的 .htaccess sn-ps。您是否无法确定文件的放置位置?
  • @Zach L 我从网上获得的 htaccess 脚本之一,似乎无法在 RewriteRule 上使用 RewriteEngine (/somedirectory/([a-z]+)$ $1.php?$2=$3 [L]

标签: php


【解决方案1】:

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

只有 htaccess 可以帮助完成这项任务。

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

【讨论】:

  • 这就是我的意思......如何用 htaccess 来做......介意分享......我一直在网上关注几个教程,但似乎没有用
猜你喜欢
  • 1970-01-01
  • 2011-06-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-21
  • 1970-01-01
  • 2016-10-23
相关资源
最近更新 更多