Nginx 關於rewrite的配置錯誤

1. 訪問 salary index.php可以,但是訪問其下 webroot/index.php就不管用了

原因是: documentRoot 應該指向 /salary/webroot 下面


2. nginx 訪問都正常,但是提交的時候 www.salary.local/user/loginCheck 出現 Not Found 404 錯誤

原因是: nginx 也是需要配置rewrite規則的

在 /usr/local/nginx/conf/vhost 中 編輯自定義的 salary.local.conf 文件


紅色部分為 rewrite規則:

server

{

listen 80;

server_name salary.local www.salary.local;

index index.html index.htm index.php;

root /home/wwwroot/salary/webroot;

if (!-f $request_filename) {

rewrite ^(.*)$ /index.php?url=$1;

break;

}


location ~ .*\\.(php|php5)?$

{

try_files $uri =404;

fastcgi_pass unix:/tmp/php-cgi.sock;

fastcgi_index index.php;

include fcgi.conf;

}


location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}


location ~ .*\\.(js|css)?$

{

expires 12h;

}


access_log off;

}


分享到:


相關文章: