0

I want to redirect both https://website.me/ and https://www.website.me/ to https://es.website.me/


This rule doesn't work

RewriteCond %{HTTPS} !^on$
RewriteRule (.*) https://es.website.me/$1 [R,L]
Olaf Dietsche
  • 69,448
  • 7
  • 95
  • 188

4 Answers4

2

Use below htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?website\.me$ [NC]
RewriteRule ^(.*)$ https://es.website.me/$1 [R=301,L]
Amit Verma
  • 39,545
  • 18
  • 87
  • 107
Ravi
  • 6,311
  • 1
  • 23
  • 41
0

Try this one for redirection in your case:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website.me$ [OR]
RewriteCond %{HTTP_HOST} ^www.website.me$
RewriteRule (.*)$ https://es.website.me/$1 [R=301,L]
</IfModule>
Mohammad Sayeed
  • 1,845
  • 1
  • 15
  • 27
0

Do you want to redirect, or rewrite?

To redirect with a code 301 (permanently moved), make 2 virtual hosts; one for the real site, and one for all the URL's you want to redirect. In the redirect host, add this line:

Redirect 301 / https://es.website.me/

Ben Hillier
  • 2,116
  • 1
  • 9
  • 14
0

Since you want to redirect only if HTTPS is already used, you must check for it, together with the hostname of course.

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(www\.)?website\.me$ [NC]
RewriteRule ^ https://es.website.me%{REQUEST_URI} [R,L]

When everything works as it should, you may replace R with R=301. Never test with R=301.

Community
  • 1
  • 1
Olaf Dietsche
  • 69,448
  • 7
  • 95
  • 188