combining rewrite rules in htaccess stops access to $_GET variables

132
February 03, 2018, at 03:49 AM

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
Answer 1

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.

READ ALSO
Calendar in Symfony 4, how can i build a dinamic where in query?

Calendar in Symfony 4, how can i build a dinamic where in query?

I'm building a calendar in Symfony 4, and I'm experiencing the problem I'm submitting to youIn a repository I created the following query:

283
Alignment with Particals.js within wordpress

Alignment with Particals.js within wordpress

Need some help with aligning javascript within my site, currently building a site within WordPress using Elementor, I am using a plugin to help me embed ParticalsJS to my site by inputting the JSON file and then reference the CSS ID within the container...

172
Wordpress not displaying options page after updating

Wordpress not displaying options page after updating

I recently upgraded the ACF plugin (version ~42) to ACF Pro (version 5

141