自学网站编程,中国十大地推公司,著名的营销成功的案例,怎么做网站搜索引擎谢谢你的答案 r3wt。但是#xff0c;我猜上面的配置文件是不合适的我不想保持原样(但是对于我来说开发似乎没问题#xff0c;因为部署我宁愿为每个站点使用单独的配置文件)。所以#xff0c;别名部分和我的问题应该正确定义try_files因为我想要捕获链接以localhost / szpetr…谢谢你的答案 r3wt。但是我猜上面的配置文件是不合适的我不想保持原样(但是对于我来说开发似乎没问题因为部署我宁愿为每个站点使用单独的配置文件)。所以别名部分和我的问题应该正确定义try_files因为我想要捕获链接以localhost / szpetra开头所以我添加它并取消注释别名部分因为现在我清楚地了解root和别名whis之间的区别是什么是This will result in files being searched for in /foo/bar/bar as the full URI is appended.location /bar {root /foo/bar;}This will result in files being searched for in /foo/bar as only the URI part after /bar is appended.location /bar {alias /foo/bar;}资料来源https://forum.nginx.org/read.php?2,129656,130107现在修改后的配置文件如下所示server {listen 80;server_name localhost;access_log /var/log/nginx/localhost-access_log main;error_log /var/log/nginx/localhost-error_log info;root /var/www/localhost/htdocs/;index index.php index.html index.htm; # I used index definition here so I think I shouldnt define it under a location field.location ~ \.php$ {try_files $uri 404;include /etc/nginx/fastcgi.conf;fastcgi_pass unix:run/php-fpm.socket;}location /phpmyadmin {alias /var/www/localhost/htdocs/phpmyadmin;access_log /var/log/nginx/phpmyadmin-access_log main;error_log /var/log/nginx/phpmyadmin-error_log info;}location /samplewordpress {alias /var/www/localhost/htdocs/samplewordpress;access_log /var/log/nginx/samplewordpress-access_log main;error_log /var/log/nginx/samplewordpress-error_log info;}location /szpetra {# alias /var/www/localhost/htdocs/szpetra; #uncommenting alias helped me solve the problemaccess_log /var/log/nginx/szpetra-access_log main;error_log /var/log/nginx/szpetra-error_log info;# index index.php index.html index.htm; # this doesnt need cause I defined the indexes above in the server{} section but Im not sure that about thistry_files $uri $uri/ /szpetra/index.php?$args; # Adding this line helped me solve the problem}}