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
  • 72,253
  • 8
  • 102
  • 198

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
  • 40,709
  • 21
  • 93
  • 115
Ravi Hirani
  • 6,511
  • 1
  • 27
  • 42
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
  • 2,025
  • 1
  • 16
  • 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,126
  • 1
  • 10
  • 15
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
  • 72,253
  • 8
  • 102
  • 198