Home > Backend Development > PHP Tutorial > 一个简单的nginx配置问题

一个简单的nginx配置问题

WBOY
Release: 2016-06-06 20:38:31
Original
938 people have browsed it

请问大家,访问api.com/v1时,想让请求都请求到/www/api/v1下面,应该怎么配置?
server_name后面加path路径的,不懂怎么配置,求指点

<code>server {
    listen 80;
    server_name api.com www.api.com;
    access_log /home/wwwlogs/access_nginx.log combined;
    index index.html index.php;

    location /v1/ {
        root /www/api/v1;
    }
</code>
Copy after login
Copy after login

回复内容:

请问大家,访问api.com/v1时,想让请求都请求到/www/api/v1下面,应该怎么配置?
server_name后面加path路径的,不懂怎么配置,求指点

<code>server {
    listen 80;
    server_name api.com www.api.com;
    access_log /home/wwwlogs/access_nginx.log combined;
    index index.html index.php;

    location /v1/ {
        root /www/api/v1;
    }
</code>
Copy after login
Copy after login

<code>location /v1/ {
    alias /www/api/v1/; # 结尾的 / 需要加上,不然路径解析会被翻译成  www.api.com/v1/v1
}
</code>
Copy after login
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