简体   繁体   中英

nginx path rewrite

What I'm getting is:

/index.php/rest/item/1

However, it should be going to:

/rest/item/1

How can I rewrite every request from /index.php/rest/ to /rest/ ?

Thanks!

Edit: It seems to only work if I make it a redirect:

rewrite ^/index.php/rest/(.*)$ /rest/$1 permanent;

If I use "break" or "last" it 404's on me, any idea? I'm using Gallery3, which is written on php's Konoha framework.

I've worked with Dmitry the past few weeks on solving this and we finally found out what the problem was. I just needed it it make sure that it doesn't finish when processing the rule. Removing the "last" or "break" from the rule fixes it:

if (!-e $request_filename) {
        rewrite ^/index.php/rest/(.*)$ /rest/$1;
        rewrite ^/(.+)$ /index.php?kohana_uri=$1 last;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM