是否有能力从Nginx获取完整的请求URI?
例如,我想从URI中获取?
和#
等字符。
我的示例Nginx配置文件(省略了一些不重要的部分):
server {
listen 80;
server_name test.dev;
root /srv/http/test/public;
index index.php;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
我的index.php:
<?php
echo '<pre>';
print_r($_GET);
echo '</pre>';die;
我使用此类网址来测试http://test.dev/"A / \\ \f b ? c.@mail.com
。
实际输出:
Array
(
[_url] => /"A / \\ \f b
[c_@mail_com] =>
)
预期产出:
Array
(
[_url] => /"A / \\ \f b ? c.@mail.com
)