网上那些配置什么alias,location,rewrite什么的都麻烦而且不好使,我就想着直接替换root 根目录配置它不香么。果然试了试就成功了,原来这么简单,我还搞了老半天。配置如下:
server{ listen 80; server_name my.com; if ($request_uri ~* ^/project1/?.*) { set $r "/var/www/project1/src/public"; } if ($request_uri ~* ^/project2/?.*) { set $r "/var/www/project2/src/public"; } root $r; index index.php index.html index.htm; access_log /var/log/nginx/your_server.access.log; error_log /var/log/nginx/your_server.error.log error; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ index.php { fastcgi_pass php:9000; fastcgi_index index.php; fastcgi_param script_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)