最近準備将本地的thinkphp架構開發的項目放到阿裡雲伺服器上,伺服器是liunx(nginx+php+mysql 環境)安正常的網站布置上去後,除了首頁其他頁面都有顯示404錯誤。于是在百毒查了一下,好像是需要設定僞靜态。也就是設定rewrite.
查找了很多關于rewrite的文章 ,搗鼓了幾次終于了可以通路 了 下面是貼出我伺服器上項目的配置檔案
阿裡雲伺服器 配置檔案在 /alidata/server/nginx/conf/vhosts/xxx.conf
root /alidata/www/對應項目的檔案夾名稱;
location /{
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~\.php{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass ..:;
fastcgi_index index.php;
include fastcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires d;
}
location ~ .*\.(js|css)?$
{
expires h;
}
#日志檔案和重定向路徑配置規則
include /alidata/server/nginx/conf/rewrite/default.conf;
access_log /alidata/log/nginx/access/項目名稱.log;