1

Before I start, let me say that I have done quite a bit of research to figure this out, but I don't think I know enough about the question to find the solution.

In my .htaccess I have a rewrite rule to send my wildcard subdomain to portal/index.php with the subdomain as a get parameter.

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]

This works perfectly, except for the fact I can no longer use $_GET variables in my script. If I visit portal.mywebsite.com/login/?reset, using var_dump() always produces array(1) { ["sub_access"]=> string(6) "portal" }

Is there a way to append $_GET variables to the generated one in my .htaccess? I'm sure I could do a work around of creating my own get variable capture by scraping the url, but I would much rather just not lose access to this feature.

I <3 $_GET
Spencer May
  • 4,266
  • 9
  • 28
  • 48
  • 1
    Use QSA to pass query string arguments – Devon Bessemer Feb 02 '18 at 17:51
  • To those visiting: https://stackoverflow.com/questions/12551382/what-does-1-qsa-l-mean-in-my-htaccess-file – Spencer May Feb 02 '18 at 17:55
  • and https://stackoverflow.com/questions/16468098/what-is-l-in-qsa-l-in-htaccess @SpencerMay which the answer in there explains what the QSA means; I feel the answer given below should have explained it and for future visitors. – Funk Forty Niner Feb 02 '18 at 18:02

1 Answers1

2

Change

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

to

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

To append then remaining query string.

Halcyon
  • 57,230
  • 10
  • 89
  • 128