[英]nginx rewrite not end with .php extension
I'm using nginx to rewrite a URL like 我正在使用nginx重写URL,例如
http://www.sample.com/application
to http://www.sample.com/index.php/application
http://www.sample.com/application
到http://www.sample.com/index.php/application
rewrite rule is 重写规则是
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 break;
}
My fastcgi config is 我的fastcgi配置是
location ~ \index.php {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
But the rewrite rule is not working. 但是重写规则不起作用。
And I browse http://www.sample.com/index.php/application
is not working also. 而且我浏览
http://www.sample.com/index.php/application
也无法正常工作。
the /application
not passing to index.php /application
不传递给index.php
What's wrong with it? 它出什么问题了?
If you break
from a rewrite
rule, the location context remains unchanged. 如果您
break
了rewrite
规则,则位置上下文将保持不变。 You need to use last
not break
so that your fastcgi location is eventually found. 您需要使用
last
not break
以便最终找到您的fastcgi位置。
Also, you have a redundant backslash in your regex rule. 另外,您的正则表达式规则中有多余的反斜杠。 It should probably be:
它可能应该是:
location ~ ^/index.php { ... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.