【问题标题】:combining rewrite rules in htaccess stops access to $_GET variables在 htaccess 中组合重写规则会停止访问 $_GET 变量
【发布时间】:2018-07-13 06:49:55
【问题描述】:

在我开始之前,让我说我已经做了很多研究来解决这个问题,但我认为我对这个问题了解得不够多,无法找到解决方案。

在我的.htaccess 中,我有一个重写规则,将我的通配符子域发送到portal/index.php,并将子域作为获取参数。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !index\.php
RewriteCond %{HTTP_HOST} ^(.+?)\.mywebsite\.com$
RewriteRule .* /portal/index.php?sub_access=%1 [L]

这很好用,除了我不能再在我的脚本中使用$_GET 变量。如果我访问portal.mywebsite.com/login/?reset,使用var_dump() 总是会产生array(1) { ["sub_access"]=> string(6) "portal" }

有没有办法将$_GET 变量附加到我的.htaccess 中生成的变量?我确信我可以通过抓取 url 来创建自己的 get 变量捕获,但我宁愿不要失去对这个功能的访问权限。

I <3 $_GET

【问题讨论】:

标签: php .htaccess mod-rewrite get


【解决方案1】:

改变

RewriteRule .* /portal/index.php?sub_access=%1 [L]

RewriteRule .* /portal/index.php?sub_access=%1 [L,QSA]

追加剩余的查询字符串。

【讨论】:

    猜你喜欢
    • 2018-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多