WordPress 301 redirect with questionmark ? from one domain to new domain with different url structure

I tried a lot, looked in the other posts but didn’t get it to work..

  1. I want to redirect olddomain.com/?portfolio=this-is-the-title-of-the-post to newdomain.com/portfolio/newtitle1/

    Read More
  2. I want to redirect olddomain.com//?portfolio=10689 to newdomain.com/portfolio/newtitle2/

  3. I want to check if mu redirect olddomain.com to newdomain.com is set correct

UPDATE: After your first answers I updated it to this but still not working:

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

Related posts

2 comments

  1. Try these 2 rules at top of your .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.
    
  2. You forgot to add RewriteEngine On before below rules:

    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]
    

Comments are closed.