![](/img/trans.png)
[英]how to redirect request for lost files to different server (nginx configuration)?
[英]nginx configuration. how to give different web sites different names?
我有一个从sites-enables / qooxdoo指向/var/www/qooxdoo/nginx.conf的指针,其中有以下内容:
server {
listen 80; ## listen for ipv4; this line is default and implied
root /var/www/qooxdoo;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
}
访问该网站,我需要做:localhost /就是这样。 但是如何命名该网站?
例如,排序localhost / site1。
预先感谢您的帮助jenia ivlev
取决于您确切想要实现的目标。 考虑文件系统中的以下目录。
/var/www
- site-1
- site-2
- ...
- site-n
现在,如果像这样配置nginx,则可以在URL中使用简单目录。
server {
listen 80;
root /var/www;
index index.html index.htm;
server_name localhost;
}
请求http://localhost/site-1
将返回文件/var/www/site-1/index.html
的内容(与site-2
相同,直到site-n
)。
如果要使用子域,可以执行以下操作。
server {
listen 80;
root /var/www/site-1;
index index.html index.htm;
server_name site-1.localhost;
}
server {
listen 80;
root /var/www/site-2;
index index.html index.htm;
server_name site-2.localhost;
}
server {
listen 80;
root /var/www/site-n;
index index.html index.htm;
server_name site-n.localhost;
}
请求http://site-1.localhost/
将返回文件/var/www/site-1/index.html
的内容(与site-2
相同,直到site-n
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.