I want to redirect all my website to another domain except 1 directory
For example:
OldDomain.com TO NewDomain.com
OldDomain.com/blabla TO NewDomain.com/blabla
OldDomain.com/blabla/page.php TO NewDomain.com/blabla/page.php
BUT!!!!
OldDomain.com/wp-admin STAY OldDomain.com/wp-admin
OldDomain.com/wp-admin/?something-blabla STAY OldDomain.com/wp-admin/?something-blabla
with htaccess only.
Try this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^OldDomain.com$
RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^(wp-admin/.*)$ $1?%1 [L]
RewriteCond %{HTTP_HOST} ^OldDomain.com$
RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^(.*)$ NewDomain\.com/$1?%1 [R=301,L]
The first rule should rewrite OldDomain.com/wp-admin/* to itself, and because auf the [L]
flag, should stop processing.
The second rule should redirect the rest to NewDomain.com.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.