Nginx-Konfigurationsproblem: Das angegebene Verzeichnis schränkt den Browserzugriff ein
仅有的幸福
仅有的幸福 2017-05-16 17:21:11
0
3
746
server {
    listen 80;
    server_name 域名已隐藏;
    index index.html index.htm index.php;
    root /home/wwwroot;
    
    # 这一段有什么问题吗 怎么不起作用
    location /app/ {
        if ($http_user_agent ~* "MicroMessenger") {
            set $notweixin 1;
        }
        if ($notweixin) {
            return 404;
        }
    }

    location ~ .*\.(php|php5)?$ {
        fastcgi_pass unix:/dev/shm/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
    expires 30d;
    }
    location ~ .*\.(js|css)?$ {
    expires 7d;
    }
}
仅有的幸福
仅有的幸福

Antworte allen(3)
漂亮男人

直接在 if ($http_user_agent) 里 return 404 不行吗?

洪涛

正则匹配优先级高于路径匹配,也就是说如果你url路径后缀是php的话,是匹配不到的

左手右手慢动作

location ^~ /app/

这样呢?

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!