小编Rai*_*aiN的帖子

NGINX 使用查询字符串重定向 URL

我有这个 NGINX 配置:

root    /var/www/web;
index   index.php;

server_name  domain.com;
access_log  off;
error_log on;

location / {
    rewrite ^/(.*)$ /index.php?tag=$1&page=1 last;
}
Run Code Online (Sandbox Code Playgroud)

现在,我想将“domain.com/index.php?tag=1§ion=2&type=3”之类的网址重定向到“domain.com/tag/section/type”

我该怎么做,我应该把代码放在哪里?请帮忙,

谢谢

我已经尝试过:

location / {
   rewrite ^/index\.php?tag=(.*)&section=(.*)&type=(.*)$ /$1/$2/$3 permanent;
   rewrite ^/(.*)$ /index.php?tag=$1&page=1 last;
}
Run Code Online (Sandbox Code Playgroud)

但它没有用..

linux configuration webserver nginx

2
推荐指数
1
解决办法
7647
查看次数

标签 统计

configuration ×1

linux ×1

nginx ×1

webserver ×1