I am dealing with an API that is accessing an URL on my website and adding
/?parameter1=value¶meter2=value to the url. I want my htaccess to handle this request and only keep the parameter's values. The API is also adding many other parameters in the query string but I just want to keep two of them.
The following does not work:
RewriteCond %{QUERY_STRING} ^parameter1=([^&]+)
RewriteCond %{QUERY_STRING} ^parameter2=([^&]+)
RewriteRule ^my-url/?$ controller.php?parameter1=%1¶meter2=%2
How can I do that correctly?
EDIT:
Here is an example.
The url is:
http://example.com/my-url/?parameter1=value1&stuff=1&stuff2=2¶meter2=value2
The htaccess should get the parameter1 & parameter2 values.
QSAflag and just get the two parameters you want in your code.parameter2in your example, but notparameter1.$_GET["parameter1"]and$_GET["parameter2"]. Doesn't matter if there are others in array. It's no different than$_SERVERvar, which contains many parameters that you may or may not use. It's just there.