my original url following:
http://example.com/lab/file.php?id=4&idl=42
i want beautify it, making accessible through url following:
http://example.com/l/not/important/url/part/?id=4&idl=42
i tried following code, doesn't work.
rewrite /l/.*/([^/]+)/?$ /lab/file.php$1 last;
how solve?
anything after ?
query string , cannot rewritten using rewrite
directive. however, default, rewrite
append original query string anyway.
you can either rewrite uri begins /l/
or create location /l/
, example:
rewrite ^/l/ /lab/file.php last;
or:
location ^~ /l/ { rewrite ^ /lab/file.php last; }
the ^~
modifier makes prefix location take precedence on regex locations @ same level. see this document details.
in both cases, rewrite
append original query string rewritten uri. see this document details.
Comments
Post a Comment