Wordpress 301重定向带问号?从一个域到具有不同网址结构的新域

时间:2015-06-03 21:29:03

标签: wordpress .htaccess mod-rewrite redirect

我尝试了很多,看过其他帖子,但没有让它发挥作用..

  1. 我想将olddomain.com/?portfolio=this-is-the-title-of-the-post重定向到newdomain.com/portfolio/newtitle1 /

  2. 我想将olddomain.com //?portfolio=10689重定向到newdomain.com/portfolio/newtitle2 /

  3. 我想检查mu重定向olddomain.com到newdomain.com是否设置正确

  4. 更新:在您第一次回答后我将其更新为此但仍然无效:

    RewriteCond %{QUERY_STRING} ^portfolio=this-is-the-title-of-the-post$
    RewriteRule ^ http://newsite.com/portfolio/newtitle1/? [R=301,L]
    
    RewriteCond %{QUERY_STRING} ^portfolio=10689$
    RewriteRule ^ http://newsite.com/portfolio/newtitle2/? [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
    # BEGIN 301 Redirects
    Redirect 301 /index.php http://newsite.com
    Redirect 301 /cart/ http://shop.newsite.com/cart/
    Redirect 301 /my-account/ http://shop.newsite.com/my-account/
    Redirect 301 /shop/ http://shop.newsite.com/
    Redirect 301 /portfolio-one-column-standard-style/ http://newsite.com/portfolio/
    Redirect 301 /home/blog/ http://newsite.com/blog/
    Redirect 301 /about/ http://newsite.com/about/
    # END 301 Redirects
    

2 个答案:

答案 0 :(得分:0)

在.htaccess:

之上尝试这两条规则
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} portfolio=this-is-the-title-of-the-post
RewriteRule ^ http://newsite.com/portfolio/newtitle1/? [R=301,L]

RewriteCond %{QUERY_STRING} portfolio=10689
RewriteRule ^ http://newsite.com/portfolio/newtitle2/? [R=301,L]

# BEGIN 301 Redirects
RewriteRule ^(index\.php)?$ http://newsite.com/ [NC,R=301,L]
RewriteRule ^cart/ http://shop.newsite.com/cart/ [R=301,L]
RewriteRule ^my-account/ http://shop.newsite.com/my-account/ [R=301,L]
RewriteRule ^shop/ http://shop.newsite.com/ [R=301,L]
RewriteRule ^portfolio-one-column-standard-style/ http://newsite.com/portfolio/ [R=301,L]
RewriteRule ^home/blog/ http://newsite.com/blog/ [R=301,L]
RewriteRule ^about/ http://newsite.com/about/ [R=301,L]
# END 301 Redirects

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Make sure to clear your browser cache before you test.

答案 1 :(得分:0)

您忘记在以下规则之前添加RewriteEngine On

RewriteCond %{QUERY_STRING} ^portfolio=this-is-the-title-of-the-post$
RewriteRule ^ http://newsite.com/portfolio/newtitle1/? [R=301,L]

RewriteCond %{QUERY_STRING} ^portfolio=10689$
RewriteRule ^ http://newsite.com/portfolio/newtitle2/? [R=301,L]