[英]Convert directory htaccess code in to statement for nginx conf file
[英]Can I add different conf file per directory on Nginx?
我想将不同的配置文件添加到不同的目录。 例如:
root /var/www/root/html
location / {
root /var/www/root/html
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
include a.conf
include phphandler.conf
}
location /dir1/ {
root /var/www/dir1/html
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
include b.conf
}
location /dir2/ {
root /var/www/dir2/html
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
include c.conf
include phphandler.conf
}
因此,每个目录都有自己的.conf文件(egaconf,b.conf),其中包含自己的php处理选项,错误处理选项等。还有一个通用的conf文件(phphandler.conf),其中包含适用于所有子目录的配置。
这样行吗? 我想为每个子目录分开错误页面和配置文件。
另外,更新nginx是否会将/ site-available / default恢复为其默认配置?
您的问题的答案是可以,但是不要在location /
在您的主要nginx.conf
您必须编写路径以包含
例如,现在您只有一个include /etc/nginx/sites-enabled/*;
只需添加另一个include /etc/nginx/yourdir/*;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.