简体   繁体   English

使用参数将旧网址重定向到Nginx

[英]Redirecting old url to Nginx with param

I have an old URL structure like this archives.php?l=e and I moved it to a new structure archives/e 我有一个旧的URL结构,例如: archives.php?l=e ,我将其移至新的结构archives/e

I'm trying to 301 redirect all the old urls, but I have run into troubles. 我正在尝试301重定向所有旧的url,但是遇到了麻烦。 This is what I'm currently doing but it's not working. 这是我目前正在执行的操作,但是没有用。

location ^~ /list.php {
    rewrite /archives/$1/ permanent;
} 

Any help would be greatly appreciated. 任何帮助将不胜感激。

I figured it out and I have to say Nginx has some nice magic for this. 我想通了,我不得不说Nginx有一些不错的魔术。 Using arg_l solved it. 使用arg_l解决了它。 Somehow it creates a variable for each param. 它以某种方式为每个参数创建了一个变量。

location ^~ /archives.php {
    rewrite ^/archives.php$ /archives/$arg_l? permanent;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM