【问题标题】:HTAccess mod rewrite issue using QSA使用 QSA 的 HTAccess mod 重写问题
【发布时间】:2011-02-04 06:34:03
【问题描述】:

我想向 URL 添加一个参数,但目前它没有显示在 $_GET 全局中。 我的 htaccess 文件中的 sn-p 如下:

RewriteRule ^account/blogs/([0-9]+)/([^\s?]+)/?$ /account/blog.php?blogId=$1 [L,QSA]

然后在我的 php 代码中我想添加一个链接,例如:

/account/blogs/1/ThisIsWhereTheTitleGoes?delete=1

通配符(除空格外的任何字符)选项用于博客标题,因为我不知道它会是什么。我知道想在末尾添加一个查询字符串参数,例如?delete=1。但是,我不希望将其作为重写的一部分。

有人知道怎么做吗? 谢谢

【问题讨论】:

    标签: php .htaccess mod-rewrite query-string


    【解决方案1】:

    我最好的选择是简单地将 get 变量添加到正则表达式中,如下所示:

    RewriteRule ^account/blogs/([0-9]+)/([^\s?]+)/?(\?(.*))?$ /account/blog.php?blogId=$1& $4 [L,QSA]

    这会重写

    /account/blogs/1/ThisIsWhereTheTitleGoes?delete=1

    /account/blog.php?blogId=1&delete=1

    它还支持其他变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多