nginx configuration problem

WBOY
Release: 2016-09-24 09:15:11
Original
1091 people have browsed it

<code class="nginx">location /admin/ {
            root   /aaa/dist;
            index  index.html;
        }</code>
Copy after login
Copy after login

For example, if nginx has the above configuration, assume the domain name is a.com.
Then when I visit a.com/admin/index.html, nginx will go to this directory to load this static html:/aaa/dist/admin/index.html
Now if I want to use the following /admin/ How should I configure the url to find static files? Now I hope that the /admin/ part that has been matched will no longer appear in the path when searching for static files. For example, it is still the above url, a.com/admin/index.html. I hope nginx can Just take the following URL and search for it in the root directory, that is, find /aaa/dist/index.html. So how should you configure it?

Reply content:

<code class="nginx">location /admin/ {
            root   /aaa/dist;
            index  index.html;
        }</code>
Copy after login
Copy after login

For example, if nginx has the above configuration, assume the domain name is a.com.
Then when I visit a.com/admin/index.html, nginx will go to this directory to load this static html:/aaa/dist/admin/index.html
Now if I want to use the following /admin/ How should I configure the url to find static files? Now I hope that the /admin/ part that has been matched will no longer appear in the path when searching for static files. For example, it is still the above url, a.com/admin/index.html. I hope nginx can Just take the following URL and search for it in the root directory, that is, find /aaa/dist/index.html. So how should you configure it?

Change root to alias and try
alias /aaa/dist/;

The easiest way is to make a soft link in /aaa/dist/admin/index.html to /aaa/dist/index.html

server {

<code>    listen          80;
    server_name     demo.test.com;
    index           index.php index.html;
    root            /mnt/hgfs/leyvi/demo.test.com/pubilc;

    location ~.*\.(php)?$
    {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            include         fastcgi.conf;
    }</code>
Copy after login

}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!