【发布时间】:2020-01-22 19:18:59
【问题描述】:
假设我想在 URL 中编码一个包含斜杠的文章标题。如果我对文章标题进行 URL 编码,我会得到:
http://example.com/articles/foo%2fbar/view/
NGINX 将其传递给我的 FastCGI 应用程序:
http://example.com/articles/foo/bar/view/
这反而破坏了这个想法。
我注意到,如果 NGINX 正在提供一个文件,比如 /path/to/page.html,那么可以通过以下两个 URL 之一访问它:
http://example.com/path/to/page.html
http://example.com/path/to%2fpage.html
但是(例如)Apache 并非如此。
有没有办法解决这个问题?
我已经尝试过文档和 Google,但没有成功。
谢谢。
更新
nginx 配置:
worker_processes 1;
pid ./nginx.pid;
events {
worker_connections 1024;
}
http {
server_tokens off;
server {
listen 80;
server_name localhost;
location /mysite/{
fastcgi_pass unix: ./mysite.fcgi.socket;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_NAME "/mysite/";
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
}
}
【问题讨论】:
-
你的 nginx 配置是什么样的?