1
網址我有這樣的目錄結構,爲我的項目有條件前面加上路徑在NGINX
/var/www
/project-a
/data <-- configuration and user files/data
/app <-- all the code is in sub-dirs in here
/pm <-- a home brew project management app
/.pmdata <-- data used by pm
我的目標是配置NGINX這樣我就可以通過 http://project-a.dev/與http://project-a.dev/pm/項目管理訪問項目本身。
換句話說,我希望第二個url保持不變,但是如果url沒有指向/pm/*
,應該重新編寫它以使其缺少/app
作爲前綴。
我曾嘗試以下的配置,但http://project-a.dev/pm/結果在404和http://project-a.dev/第一重定向到http://project-a.dev/app/然後給出404
我在做什麼錯?
server {
listen 127.0.0.1:80;
root /var/www/project-a;
index index.php index.html index.htm;
server_name project-a.dev;
location/{
try_files $uri $uri/app $uri/app/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}