使用Nginx将域添加到子文件夹

时间:2016-06-22 19:42:01

标签: php nginx

我有很多项目,比如/ var / www / html / test,/ var / www / html / test1等。 只想将我的域名附加到其中一个文件夹中。 操作系统是Debian。这是我的网站 - 可用配置

server {
    server_name example.me;

    root /var/www/html/example.me;
    index index.html index.php;

    # set expiration of assets to MAX for caching
    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
            expires max;
            log_not_found off;
    }

    location / {
            # Check if a file or directory index file exists, else route it to index.php.
            try_files $uri $uri/ /index.php;
    }

    location ~* \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi.conf;
    }

}

我希望能帮助我解决这个问题。

1 个答案:

答案 0 :(得分:1)

以下内容将使test文件夹位于example.me

  • 将您的root /var/www/html/example.me;更改为root /var/www/html/test;
  • 将您的站点配置文件复制或符号链接到sites-enabled
  • 重新启动nginx

使用test1在不同的网站配置文件中使用正确的server_nameroot重复相同的过程。