不推荐:
直接修改 MAMP PRO 软件内的 nginx.conf 文件 /Library/Application。在
Support/appsolute/MAMP PRO/conf/nginx.conflocation / {} 把方法一的代码添加进去。
此方法虽然有效,但每次
MAMP PRO内新建/修改站点配置时,都将会被重新覆盖。
server {
server_name shop.domain.com;
listen 8080;
root "/Users/dream/Develop/your-project-file";
location / {
try_files $uri $uri/ =404;
index index.html index.php;
autoindex off;
allow all;
deny all;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
}
推荐:
在 MAMP PRO 软件内 -> 选择需要配置的站点 -> 点击右侧 Nginx 选项 -> 然后在 Custom 配置项内输入:
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
所有配置参数都建议在站点的
Nginx选项内进行操作。
PS:不要直接在File->Edit Template->Nginx(nginx.conf)中修改配置。
感谢您的阅读,本文由 蓝色梦想 版权所有。如若转载,请注明出处:蓝色梦想 - MAMP PRO 配置多站点 404 解决方案