How to redirect domains on a wordpress site, including path?
Assuming both domains are pointing to same DocumentRoot
, you can use this rule in your site root .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^ https://domain.com.br%{REQUEST_URI} [R=301,L,NE]
This rule will redirect to .br
domain if HTTPS
is not on OR host name in request is domain.com
with optional www.
before.
Make sure this is your topmost rule and you completely clear browser cache before testing.