在开始之前,请允许我说我已做了相当多的研究来解决这个问题,但我认为我对这个问题的了解并不充分。
在我的.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中生成的变量?我确信我可以通过抓取网址来创建自己的get变量捕获工作,但我更愿意不会失去对此功能的访问权限。
I <3 $_GET
答案 0 :(得分:2)
更改
RewriteRule .* /portal/index.php?sub_access=%1 [L]
到
RewriteRule .* /portal/index.php?sub_access=%1 [L,QSA]
附加剩余的查询字符串。