How to redirect domain . com . htaccess

Asked

Viewed 1,467 times

0

I have 2 domains, example.com and example.com.br pointing to the same wordpress site.

I would like to redirect every time someone enters example.com, be redirected to example.com.br/en

I found this code, but it also redirects example.com.br to /en

RewriteEngine on
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^ http://www.example.com.br/en [L,R=301]

Someone can help me?

P.S.: Preferably works both with 'www' and without.

  • Good afternoon @Amadeuantunes I think it is not a duplicate of this specific question.

1 answer

1

That should help.

RewriteEngine on
RewriteRule ^(.*)$ http://www.example.com.br/en [R=301,L]

Or try it this way:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule (.*)$ http://www.example.com.br/en [R=301,L]
</IfModule>
  • In this case .com.br also redirects, and I just want . com to redirect.

  • Well, it’s simple, put this . htaccess only in the root of . com or simply create a redirect index in each. If the 2 points to the same hosting becomes easy.

  • The 2 DNS are part of the same hosting, pointed directly by apache to the same directory. Then the 2 will read the same htaccess rule.

  • Does your hosting have cPanel? If so, you can create redirects directly in cPanel.

  • I’ll post another way editing the question, look there.

  • Unfortunately it didn’t work, but I found a solition through a plugin of WP itself. I appreciate your help.

  • Quiet. It is always good to seek alternative solutions of the probable.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.