Nginx下URL Rewrite配置
环境:CentOS5.3+Nginx 0.7,启用伪静态:
编辑/usr/local/nginx/conf/nginx.conf,在server段添加
server
{
listen 80;
server_name xxx.phoebus.cn;
index index.html index.htm index.php;
root /web/www;
location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
正需要,谢谢!