Conditional redirect by htaccess

From last 3 hours i’m trying to get a proper solution but failed. So, i think that is the time to post it here.

I have a two WordPress website.

Read More

Old Site has 4 page.
I want to redirect every request of old website redirect to new domain except that homepage, 3 other page & everything on wp-admin.

So, output will be-

http://www.sitea.com - no redirect
http://www.sitea.com/?page_id=1 - no redirect
http://www.sitea.com/?page_id=2 - no redirect
http://www.sitea.com/?page_id=3 - no redirect
Everything on wp-admin - no redirect

Everything else - redirect to http://www.siteb.com

Thanks in advnace

Related posts

1 comment

  1. You can use this rule as your very first rule in your DOCUMENT_ROOT/.htaccess file:

    RewriteEngine On
    
    # ignore these URLs
    RewriteCond %{QUERY_STRING} ^page_id=[123]$ [NC]
    RewriteRule ^ - [L]
    
    # redirect rest to siteb.com
    RewriteCond %{HTTP_HOST} !^(www.)?siteb.com$ [NC]
    RewriteRule . http://www.siteb.com/? [L,R=301]
    

Comments are closed.