iRector
iRector

Reputation: 1984

Using mod_rewrite with a single GET variable

I'm trying to rewrite a url such as:

example.com/var?id=0&blah=foo
to
example.com/?test=var&id=0&blah=foo


So far I have this in my .htaccess:

AddHandler application/x-httpd-php5s .php

RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ ?api_call=$1 [L,QSA]

Which rewrites var into ?test=var but the remaining get variables are left off.


How can this be changed to include the other GET vars?

Upvotes: 1

Views: 43

Answers (1)

anubhava
anubhava

Reputation: 785196

Try this rule:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-]+)/?$ ?api_call=$1 [L,QSA]

Upvotes: 1

Related Questions