有兩個項目一個是phpcms得,另外一個是yii2.0架構的,伺服器使用的是nginx,現在想將yii的這個項目作為子目錄直接拿過來 然後通過http://domain.com/子目錄 來訪問,但是通過配置 /子目錄 可以訪問index 但是頁面的資源檔片、css等都無法載入,圖片連結為http://domain.com/子目錄/public/images/blue_icon.png 但是還是會重新導向到子目錄下面的index.php 求教問題出在哪裡?
server{ listen 80; server_name domain.com; root /Users/xxx/www/project; index index.php; location /{ try_files $uri $uri/ /index.php?$args; autoindex on; } location /blog{ index index.php index.html; try_files $uri $uri/ /blog/index.php?$args; autoindex on; } location ~ ^(.+\.php)(.*)$ { root /Users/xxx/www/project; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
回複內容:
有兩個項目一個是phpcms得,另外一個是yii2.0架構的,伺服器使用的是nginx,現在想將yii的這個項目作為子目錄直接拿過來 然後通過http://domain.com/子目錄 來訪問,但是通過配置 /子目錄 可以訪問index 但是頁面的資源檔片、css等都無法載入,圖片連結為http://domain.com/子目錄/public/images/blue_icon.png 但是還是會重新導向到子目錄下面的index.php 求教問題出在哪裡?
server{ listen 80; server_name domain.com; root /Users/xxx/www/project; index index.php; location /{ try_files $uri $uri/ /index.php?$args; autoindex on; } location /blog{ index index.php index.html; try_files $uri $uri/ /blog/index.php?$args; autoindex on; } location ~ ^(.+\.php)(.*)$ { root /Users/xxx/www/project; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}