Reputation: 3517
What is wrong with this rewrite rule?
RewriteRule ^api/(.+)$ api/index.php?url=$1 [L]
I simply want "index.php?url=" to be added after api/ and before the rest of the get parameters.
api/image/upload&arg1=1&text=lorem+ipsum
to
api/index.php?url=image/upload&arg1=1&text=lorem+ipsum
What is wrong with (.+) to get everything after api/?
Upvotes: 10
Views: 14210
Reputation: 239910
The regex on the RewriteRule is only run against the path part of the URL, not the query parameters. Fortunately there is the [QSA]
flag to preserve existing query parameters.
Upvotes: 22
Reputation: 2803
I think you must write your domain name before the regex stuff. Like this:
RewriteRule ^(.+).com/api/(.*)$ "$1.com/api/index.php?url=$2" [R=301,L]
Upvotes: 0
Reputation: 89172
Are you doing something to stop infinite recursion?
RewriteRule ^api/(.+)$ api/index.php?url=$1 [R=301,L]
or some equivalent
Upvotes: 0