【问题标题】:GET parameters cant retrieve using phpGET参数无法使用php检索
【发布时间】:2014-12-04 14:14:51
【问题描述】:

我正在处理一个无法从浏览器 url 检索 GET 参数值的 php 页面

ex- 如果我通过浏览器传递以下网址

http://www.test.com/afvalbakken?price[]=&price[]=&17[]=&17[]=&16[]=107&18[]=180

var_dump($_GET) 数组下面的输出。它不显示传递的参数

array(1) {
  ["url"]=>
  string(11) "afvalbakken"
}

我使用 htaccess 文件来重写一些 url。下面有它的代码

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1 [L]

谁知道如何访问这些get参数,谢谢

【问题讨论】:

    标签: php .htaccess mod-rewrite url-rewriting get


    【解决方案1】:

    这里需要QSA 标志:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]
    

    QSA(查询字符串附加)标志在添加新参数时保留现有查询参数

    【讨论】:

    • 太好了,这似乎工作正常,这对网站当前的 url 重写系统会有影响吗,谢谢
    • 不,它不会影响任何重写。
    猜你喜欢
    • 2015-11-02
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    • 1970-01-01
    • 1970-01-01
    • 2015-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多