Nginx Rewrite Apache?

Francis Daly francis at daoine.org
Mon Apr 18 15:57:48 MSD 2011


On Fri, Apr 15, 2011 at 05:36:09PM -0400, Adrian Janeczek wrote:

Hi there,

> This is uri but i use this conf 

> and this not work

What do you expect to see it do; and what do you see it do instead?

As before, the debug log (http://nginx.org/en/docs/debugging_log.html)
is frequently helpful in finding the problem cause.


>     location / {
>         if (!-e $request_filename) {
>             rewrite ^/(.*)$ /index.php?$1 last;
>         }
>     }

That may be better with try_files
(http://wiki.nginx.org/NginxHttpCoreModule#try_files), but probably
isn't the main problem you're seeing.

>     location ~ .php($|/) {
>  
>         set $script     $uri;
>         set $path_info  "";
>  
>         if ($uri ~ "^(.+.php)(/.+)") {
>             set $script     $1;
>             set $path_info  $2;
>         }

Using "if" inside "location" for anything other than "return" or
"rewrite...last" is usually unwise. See http://wiki.nginx.org/IfIsEvil
for details.

In this case, I would suggest using fastcgi_split_path_info, since that's
what you're trying to do.

http://wiki.nginx.org/HttpFcgiModule#fastcgi_split_path_info

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list