Rewrite
Edho Arief
edho at myconan.net
Thu Apr 19 23:56:51 UTC 2012
2012/4/20 Silvio Siefke <siefke_listen at web.de>:
> Hello,
>
> i want use rewrite to use article-"id".php to the post.php?id=1 for example.
> I has written the follow in the server section:
>
> location /article-(\d+)\.php$ {
> try_files $uri $uri/ /post.php?id=$1;
> }
>
> But it want not run. When i give http://example.com/blog/article-1.php,
> nginx not change to http://example.com/blog/post.php?id=1
>
1. you forgot to put ~ for regex match
2. the one you want is rewrite/return, not try_files
something like this may work:
location ~ ^/article-(\d+)\.php$ {
rewrite ^ /post.php?id=$1 last;
}
More information about the nginx
mailing list