【问题标题】:Rewriting Url With .htaccess for Muliple Parameters使用 .htaccess 为多个参数重写 Url
【发布时间】:2015-08-19 15:26:15
【问题描述】:

我想用 .htaccess 重写 url 请阅读代码,你就会明白我的意思

我的网址:

article.php?id=1&title=example

在 .htaccess 中使用它

 RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+)$
 article.php?id=$1&title=$2 [NC,L]

我明白了

article/1/example

我需要的是

article/example

【问题讨论】:

    标签: php apache mod-rewrite url-rewriting


    【解决方案1】:

    所以是这样的:

    RewriteRule ^article/([0-9a-zA-Z_-]+)$ article.php?title=$1 [NC,L]
    

    【讨论】:

    • gng 试试,让你知道.. thnx 寻求帮助:)
    • 在 article.php 中我通过从查询字符串中获取 id 来运行查询,它不会与 this article.php?title=$1 一起执行。
    • 你要求删除它,如果你需要它,你必须把它放在 url 中
    • 有什么方法可以从我的数据库中获取标题。 id 和 title 都在同一行 mysite.com/profile.php?id=23 mysite.com/gorki 类似这样的东西..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-07
    • 2013-03-05
    • 1970-01-01
    • 2021-06-29
    相关资源
    最近更新 更多