![如何使用 nginx 根据请求位置的变量值进行重定向?](https://linux22.com/image/732143/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20nginx%20%E6%A0%B9%E6%8D%AE%E8%AF%B7%E6%B1%82%E4%BD%8D%E7%BD%AE%E7%9A%84%E5%8F%98%E9%87%8F%E5%80%BC%E8%BF%9B%E8%A1%8C%E9%87%8D%E5%AE%9A%E5%90%91%EF%BC%9F.png)
我是从 apache 开始接触 nginx 的新手,我正在尝试执行遵循这种简单格式的重定向。
http://sub.domain.tld/location=BLAH
应该重定向到
http://sub.domain.tld/location/directory1/directory2/BLAH/index.html
sub.domain.tld 启用了 http 和 https--不确定是否有区别。
当前服务器配置:
server {
server_name sub.domain.tld;
listen 1.2.3.4:80;
listen [dead:beef:feed:deed::]:80;
root /path/to/web/root/;
if ($request_method !~ ^(GET|HEAD|POST)$ ) { return 444; }
location / {
index will.never.exist.xyz;
try_files $uri $uri/ =404;
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime off;
}
listen [dead:beef:feed:deed::]:443 ssl;
listen 1.2.3.4:443 ssl;
ssl_certificate /path/.../fullchain.pem;
ssl_certificate_key /path/.../privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}