How do you redirect the same slug on 2 different domains in a WordPress Network?
-
I have a WordPress network setup as a sub-directory install and everything is working properly accept for a small problem, I need to setup two redirects one for each domain both would be redirected to a sub-domain. Because a WordPress network uses only one single .htaccess file this only seems to work for the two redirects in place for the main network domain but not the other mapped domain.
The main domain in the network is bchyundai.com and I have mapped the domain name bcmazda.com to the network blog bchyundai.com/bcmazda1/ Now I am having an issue because I need the same slug redirected for each domain (bcmazda.com & bchyundai.com). Here is what I have now that works for half of the goal:
Redirect 301 /browse/view_detailed/type_used/ https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/ Redirect 301 /browse/view_detailed/type_new/ https://newcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_new/ RewriteEngine On RewriteCond %{HTTP_HOST} ^BCHYUNDAI.com [NC] RewriteRule ^(.*)$ https://www.BCHYUNDAI.com/$1 [L,R=301] RewriteEngine On RewriteCond %{HTTP_HOST} ^BCMAZDA.com [NC] RewriteRule ^(.*)$ https://www.BCMAZDA.com/$1 [L,R=301] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L] RewriteRule . index.php [L]
The goal is for:
https://www.bchyundai.com/browse/view_detailed/type_used/ to redirect to https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/
and
https://www.bcmazda.com/browse/view_detailed/type_used/ to redirect to https://usedcars.bcmazda.com/bcmazdav2/browse/view_detailed/type_used/
Which thanks to this informational post about WordPress multisite redirects I have gotten closer I think to making this work. But none-the-less, it still doesn’t work even using his suggested redirect. Here is what I’ve tried but doesn’t work:
RewriteEngine On RewriteCond %{HTTP_HOST} ^BCHYUNDAI.com [NC] RewriteRule ^(.*)$ https://www.BCHYUNDAI.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^(www\.)?bchyundai.com\.told [NC] RewriteRule ^bchyundai.com/browse/view_detailed/type_used/\.aspx$ https://usedcars.bchyundai.com/bchyundaiv2/browse/view_detailed/type_used/ [R=301,NC,L] RewriteEngine On RewriteCond %{HTTP_HOST} ^BCMAZDA.com [NC] RewriteRule ^(.*)$ https://www.BCMAZDA.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^(www\.)?bcmazda.com\.told [NC] RewriteRule ^bcmazda.com/browse/view_detailed/type_used/\.aspx$ https://usedcars.bcmazda.com/bcmazdav2/browse/view_detailed/type_used/ [R=301,NC,L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L] RewriteRule . index.php [L]
So the question is, how do you redirect the same slug on two different domains in a single .htaccess file? Is there a way to make two .htaccess files? One for each domain or site on the network?
- The topic ‘How do you redirect the same slug on 2 different domains in a WordPress Network?’ is closed to new replies.