3

I am dealing with an API that is accessing an URL on my website and adding "/?parameter=value" to the url. I want my htaccess to handle this request and only keep the parameter's value. I want to keep it simple.

RewriteRule ^my-url/\?parameter=(.*)$ controller.php?parameter=$1

RewriteRule ^my-url/.parameter=(.*)$ controller.php?parameter=$1

Both of the above does not work. There seem to be an issue handling the question mark.

Peter Lur
  • 698
  • 2
  • 10
  • 26

1 Answers1

3

You need to use a RewriteCond to match QUERY_STRING:

RewriteCond %{QUERY_STRING} ^parameter=([^&]+)
RewriteRule ^my-url/?$ controller.php?parameter=%1 [L,QSA]
anubhava
  • 713,503
  • 59
  • 514
  • 593