【问题标题】:How to redirect to new domain without parameters如何在没有参数的情况下重定向到新域
【发布时间】:2019-10-15 16:41:26
【问题描述】:

我目前正在尝试将旧域重定向到新域,但遇到了一个小问题。我只想做 1 个不带参数的 301 重定向...

现在我有这个 -> olddomain.com/?dmdald -> newdomain.com/?dmdald -> newdomain.com

所以基本上我不得不使用两个 301 重定向,因为参数仍然存在。有什么办法可以在下面做到这一点吗?我正在使用 wordpress。

olddomain.com/?dmdald -> newdomain.com

我使用了下面的代码,它最终可以得到最终结果,但不幸的是它仍然使用两个重定向。

RewriteCond %{QUERY_STRING} !=""
 RewriteCond %{QUERY_STRING} !^p=.*
 RewriteCond %{QUERY_STRING} !^s=.*
 RewriteCond %{REQUEST_URI} !^/wp-admin.*
 RewriteRule ^(.*)$ /$1? [R=301,L]

【问题讨论】:

    标签: wordpress url redirect parameters


    【解决方案1】:

    在 .htaccess 文件中检查这个重写

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
    RewriteRule (.*) http://newdomain.com/$1? [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-31
      • 2016-12-13
      • 1970-01-01
      相关资源
      最近更新 更多