1
votes

I am having trouble using .htaccess to internally rewrite (that is, use the requested URL to form an internal request to then provide that to the client, who still only sees the original requested URL) a URL where only one parameter is prettified, and the rest of the request parameters are still appended. Other posts on stack either concern just one relevant parameter, or wish to redirect every parameter.

That is,

I can do this for the first bullet, a single parameter rewrite;

RewriteEngine on
RewriteBase /

#Prettify test
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?overhoringen/open/([^/]+)/?$ /overhoringen/open.php?testId=$1 [L]

However, I am unsure how to capture the request query at the end and then append it to the internal redirect (if present at all), without the ? still in front (to avoid open?testId=9?other=param&more=param), etc.
Help with this would just be really cool. :]

1
You need QSA parameter - akond
@akond while this seems perfect, a php $_GET readout still only registers the testId parameter.. :/ - Isaiah
@akond I had appended the QSA parameter as [L][QSA], instead of [L,QSA], which was the problem - Isaiah

1 Answers

2
votes

Change this line:

RewriteRule ^/?overhoringen/open/([^/]+)/?$ /overhoringen/open.php?testId=$1 [L]

to:

RewriteRule ^/?overhoringen/open/([^/]+)/?$ /overhoringen/open.php?testId=$1 [L,QSA]

Adding QSA should append the additional query string to the new url.