【问题标题】:Nginx: Redirect search 301Nginx:重定向搜索301
【发布时间】:2016-02-03 11:57:29
【问题描述】:

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

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

例如:

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;
}

【问题讨论】:

    标签: wordpress redirect nginx


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,理查德!有效!
    猜你喜欢
    • 2020-10-29
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多