【问题标题】:PHP GET Method without index.php?id=XXX [duplicate]没有 index.php?id=XXX 的 PHP GET 方法 [重复]
【发布时间】:2016-07-16 18:39:21
【问题描述】:

我已经(在PHPPDO 中)编写了一个链接收缩器,它可以与GET 方法(index.php?id=1) 一起使用,但我希望它是这样的:domain.com/[ID]

【问题讨论】:

  • 阅读 URL 重写。这就是你似乎在寻找的东西。但是你必须如何实现它取决于你使用的网络服务器,所以这个问题缺少正确答案的细节。

标签: php html apache


【解决方案1】:

在您的主文件夹中创建 .htaccess 文件并在文件中写入以下内容

RewriteEngine On

RewriteRule ^([a-zA-Z0-9-/]+)$ index.php?id=$1 [L]

结果

domain.com/1 = domain.com/index.php?id=1

domain.com/home = domain.com/index.php?id=home

domain.com/ID = domain.com/index.php?id=ID

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-30
    • 2013-12-23
    • 2011-10-07
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    • 1970-01-01
    • 2015-01-16
    相关资源
    最近更新 更多