• Home
  • Jobs
  • Courses
  • Teachers
  • For business
  • Blog
  • ES/EN

0

18
Views
Nginx set root to subfolder

With Nginx, i need the download folder to become the home page of my website, while still allowing the terms.html page to appear at the root. The download folder displays the list of files with the fancyindex and fancyindex_header directives.

I did this: root /var/www/html/download; but I no longer have access to pages outside the download folder like terms.html

does nginx allow this configuration? here is the structure of my directories:

www/
    /download/  # fancyindex on + home page
    /account/
            /index.php
            /login.php
            /signup.php
    /css/
    /js/
    robots.txt
    terms.html
16 days ago ·

Santiago Trujillo

1 answers
Answer question

0

If your directory structure follows your URI structure, you should probably set the root to /var/www/html at the server level and use /var/www/html/download for one location only.

For example:

server {
    ...
    root /var/www/html;

    location / {
        root /var/www/html/download;
        fancyindex on;
    }
    location /account/ {
        ... # PHP stuff
    }
    location /css/ { }
    location /js/ { }
    location = /robots.txt { }
    location = /terms.html { }

The last four blocks can be empty, as they inherit the value of root from the surrounding block. See this document for details.

16 days ago · Santiago Trujillo Report
Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.