繁体   English   中英

在htaccess中结合重写规则将停止对$ _GET变量的访问

[英]combining rewrite rules in htaccess stops access to $_GET variables

在开始之前,请允许我说我已经做了大量的研究来弄清楚这一点,但是我认为我对这个问题的了解不足以找到解决方案。

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

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

更改

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

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

然后追加剩余的查询字符串。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM