【问题标题】:.htaccess URL Rewrite doesn't see get values.htaccess URL Rewrite 看不到获取值
【发布时间】:2018-05-01 21:02:49
【问题描述】:

我想重写我的网址:

http://localhost/api/user/?a=xxx&b=yyy

到:

http://localhost/?controller=user&a=xxx&b=yyy

我写的

RewriteRule ^api/([a-z]*)/\\?(.*)$ ?controller=$1&$2 [L]

但是它在第一个链接中看不到我的获取值。有没有可能这样做?

【问题讨论】:

    标签: regex .htaccess url url-rewriting


    【解决方案1】:

    尝试从查询中获取数据时,您只需匹配路径并添加[QSA] 在你的情况下:

    RewriteRule ^api/([a-z]+)$ ./index.php?controller=$1 [QSA, L]
    

    注意,我加了./index.php,替换成你要执行的原文件。

    【讨论】:

      猜你喜欢
      • 2012-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多