Magento – Magento HTACCESS query 301 redirect all but admin

.htaccess301-redirectmagento-1.9url-rewrite

Hi hopefully someone can help.
I have added a 301 redirect to change from an old domain name to a new domain.
The magento build is still on the old domain also (but with no follow / no index)

I want to keep the installation on the old domain also for order reference etc.

I have added the following to the hta access file, but obviously this also stops me being able to access the admin side of the site.

How can I add an exclude on the following so that I can redirect all – apart from the admin and so this can still be accessed.

#Redirect from old domain to new domain
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.b.co/$1 [R=301,L]

Best Answer

You can try the following:

RewriteEngine on 
RewriteBase / 
RewriteCond %{REQUEST_URI} !^/admin
RewriteCond %{REQUEST_URI} !^admin
RewriteCond %{REQUEST_URI} !^/index.php/admin
RewriteCond %{REQUEST_URI} !^index.php/admin
RewriteRule (.*) http://www.b.co/$1 [R=301,L]

You can change admin if you use another path for your admin area.

Related Topic