Nginx:重定向搜索301

时间:2016-02-03 11:57:30

标签: wordpress redirect nginx

我正在使用 nginx ,我在我的面板中发现多个 404错误用于搜索,因为我将joomla迁移到wordpress。

我需要在nginx中进行重写,但我需要帮助...

例如:

404网址:

http://example.com/component/search/?searchword=shoes&ordering=&searchphrase=all

http://example.com/component/content/?view=featured&start=220

将是:

http://example.com/?s=shoes
http://example.com

Nginx的:

server {

     #Other server configs...
     rewrite ^component/search/?searchword=$ http://example.com/?s= permanent;
}

1 个答案:

答案 0 :(得分:0)

如果URI /component/search//component/content/对于之前的实施而言是唯一的,那么设置两个前缀位置可能是最有效的解决方案:

location /component/search/ {
    return 301 $scheme://$host/?s=$arg_searchword;

location /component/content/ {
    return 301 $scheme://$host/;
}