Rewrite a Shortened URL to a Pretty URL?

Edho Arief edho at myconan.net
Sat Sep 1 17:52:00 UTC 2012


On Sun, Sep 2, 2012 at 12:46 AM, slevytam <nginx-forum at nginx.us> wrote:
> Hi,
>
> Thank you for your reply.  Sorry for the late response but the forum didn't
> notify me of your post.
>
> I tried your suggestion.
>
> rewrite ^/(.*?)/.*$ /entry/index.php?id=$1 permanent;
>
> It works for http://www.domain.com/1234/pretty-url-goes-here but it does not
> work for http://www.domain.com/1234.
>
> Also, it does not leave the url as entered.  So, for example, if you input
> http://www.domain.com/1234/pretty-url-goes-here it changes the address bar
> to http://www.domain.com/entry/id=1234 instead of staying at the pretty
> url.
>
> Any thoughts?
>

rewrite ^/(\d+)(/|$) /entry/index.php?id=$1;



More information about the nginx mailing list