wordpress and htaccess 301 redirect without admin

I’m trying to redirect my entire blog to a new domain without redirecting the admin area.
The code I use is as follows:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^old-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp-login
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]

But still I’m getting redirected to the new domain when I go to old-domain.com/wp-admin

Read More

Can anybody help?

Thanks.

Related posts

Leave a Reply

2 comments

  1. Try:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^old-domain.com$ [NC]
    
    RewriteCond %{REQUEST_URI} !^(.*)?wp-login.php(.*)$
    RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
    
    RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
    
  2. This worked for me…

    # Redirect all requests except wp-admin
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_URI} !^(.*)?wp-login.php(.*)$
    RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
    RewriteCond %{REQUEST_URI} !^/(wp-includes/.*|wp-admin/.*|wp-content/.*)$
    
    RewriteRule ^(.*)$ http://new.com [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