简体   繁体   中英

Add domain to subfolder with Nginx

I have many projects like, /var/www/html/test, /var/www/html/test1 etc. Just wanna to attach my domain to one of these folders. OS is Debian. Here is my sites-available config

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;
    }

}

I hope any help me with this one thx a lot.

The following will make your test folder available at example.me .

  • Change your root /var/www/html/example.me; to root /var/www/html/test;
  • Copy or symlink your site configuration file to sites-enabled
  • Restart nginx

Repeat the same process with test1 in a different site config file and with the correct server_name and root .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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