Reputation: 91
I'm very new to nginx and just working with the rewrite rule
I want my domain http://example.com/database/view.php?id=1
to show as http://example.com/database/id/
with the GET parameter showing in the url where "id" is, is that possible?
I have attempted this :
rewrite ^/database/$arg_id? /database/view.php?id=[1-9]* last;
and
location @database {
rewrite ^/view/(.*) /view.php?id=$1&$args last;
}
and they failed resulting in example.com/database/view/51 as a 404
Upvotes: 6
Views: 6151
Reputation: 91
Fixed it :)
Solved with
rewrite ^/view/(.*)/ /database/view.php?id=$1&$args last;
Upvotes: 3