简体   繁体   English

Nginx子域:重定向到错误的目录

[英]Nginx subdomain: redirecting to wrong directory

I have a domain (let it be example.com ). 我有一个域(将其设置为example.com )。 Also, I have a configured nginx web server, where example.com is pointed to the root directory /var/www/example . 另外,我有一个已配置的Nginx Web服务器,其中example.com指向根目录/ var / www / example Then, I wanted to point service.example.com to /var/www/example , and then point the original example.com to /var/www/service Fisrt lines of nginx config for service.example.com look like this: 然后,我想将service.example.com指向/ var / www / example ,然后将原始example.com指向/ var / www / service的 Nginx配置的Fisrt行,用于service.example.com,如下所示:

server {

    server_name service.example.com;

    root /var/www/example;

......

It works, and when I try to access service.example.com, I'm being redirected to the index file in /var/www/example. 它有效,当我尝试访问service.example.com时,我被重定向到/ var / www / example中的索引文件。

Then, I made a config for example.com: 然后,我为example.com进行了配置:

server {

    server_name example.com www.example.com;

    root /var/www/service;

......

,but when I'm trying to access example.com , I see the index file of /var/www/example — as if I tried to access service.example.com . ,但是当我尝试访问example.com时 ,会看到/ var / www / example的索引文件-就像我试图访问service.example.com一样

So, how can I solve this problem, and see index file of /var/www/service when I'm trying to access example.com ? 因此,如何解决此问题,并在尝试访问example.com时看到/ var / www / service的索引文件?

Problem was in symlinks. 问题出在符号链接中。

Some of them was not the symlinks in sites-enabled, but archive. 其中一些不是启用站点的符号链接,而是归档文件。 So, nginx didn't handled them. 因此,nginx没有处理它们。

Problem was solved! 问题解决了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM