yevic tabita
yevic tabita

Reputation: 59

Domain too many redirection

Hi after 1 week of research i'm still stuck with my domain redirections I want my http://domain.fr pointing to https://www.domain.fr I'm trying with htaccess file with no success...

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.*
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

When i'm testing my redirections it seems https://www.domain.fr is redirecting itself without understading why... have you guys any idea ?

Upvotes: 1

Views: 23

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

The problem is in your 2nd RewriteRule

RewriteCond %{HTTP_HOST} ^www\.*
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

You rule does a permanent redirection of www domain to the same location ie : ( www.e ample.com => www.example.com ) that is why you got the redirect loop error.

To redirect http urls to https ,first of all you need to check if the request scheme is http. You can use RewriteCond %{HTTPS} off to check the non - secure http connection and then use RewriteRule to redirect the request to https .

Use the following simple Rule to redirect http to https :

RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

Make sure to clear your browser cache before testing this.

Upvotes: 1

Related Questions