简体   繁体   English

nginx 位置指令

[英]nginx location directive

I have an nginx server with a rails app.我有一个带有 rails 应用程序的 nginx 服务器。 my nginx.conf is我的 nginx.conf 是

server {
      listen 80;
      server_name nerto.it;
      root /var/www/current/public; 
      passenger_enabled on;


    location /m {
        passenger_enabled off;
        index index.html index.php;
        try_files $uri $uri/ /m/index.html?q=$uri;
    }
...
}

It works except address like nerto.it/mprove or nerto.it/mtry除了像 nerto.it/mprove 或 nerto.it/mtry 这样的地址外,它可以工作

where the initial letter is /m and nginx take this address like nerto.it/m其中首字母是 /m 并且 nginx 使用这个地址,如 nerto.it/m

How can i solve it?我该如何解决?

location /m/ {
    passenger_enabled off;
    index index.html index.php;
    try_files $uri $uri/ /m/index.html?q=$uri;
}

or或者

location = /m {
    ...
}

It is unclear from your question what behaviour do you expect.从您的问题中不清楚您期望什么行为。

Please, read the documentation: http://nginx.org/r/location请阅读文档: http : //nginx.org/r/location

I think you should try smth like this:我认为你应该像这样尝试:

location ~* ^/m(.*) {

Regular expressions are specified by prepending them with the “~*” prefix (for case-insensitive matching), or with the “~” prefix (for case-sensitive matching).正则表达式通过在它们前面加上“~*”前缀(对于不区分大小写的匹配)或“~”前缀(对于区分大小写的匹配)来指定。

nginx location directive nginx 位置指令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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