1

I'm just going crazy with my issue and hope for your help.

I have one webstore with two domains linking to one same path. And webstore is choosing itself which content should be shown depends on domain.

  • www.yogabox.de - German content
  • www.yogabox.co.uk - English content

I'm trying to rewrite all kinds of yogabox.de to https://www.yogabox.de und the same for yogabox.co.uk to https://www.yogabox.co.uk

Here is the result:

enter image description here

I'm using those rules:

RewriteCond %{HTTPS}        off
RewriteCond %{HTTP_HOST}        !^www\.yogabox\.co\.uk$
RewriteCond %{HTTP_HOST}        !^yogabox\.co\.uk$
#RewriteCond %{HTTP_HOST}        !^www\.yogabox\.de$
RewriteRule ^(.*)$      https://www.yogabox.de/$1 [R=301,L]

RewriteCond %{HTTPS}        off
#RewriteCond %{HTTP_HOST}        ^yogabox\.co\.uk$
RewriteCond %{HTTP_HOST}        !^www\.yogabox\.de$
RewriteCond %{HTTP_HOST}        !^yogabox\.de$
RewriteRule ^(.*)$      https://www.yogabox.co.uk/$1 [R=301,L]

Only https://yogabox.de and https://yogabox.co.uk are wrong. Where is the problem?

I have already checked the problem with not valid certificate like here WWW to NON WWW Urls (Remove WWW) using Apache (.htaccess)

But the certificates are valid for www and without www.

Astarot
  • 61
  • 1
  • 8
  • `RewriteCond %{HTTPS} off` applies to http. What do you want for `https://yogabox.de` and `https://yogabox.co.uk`? `https://www.` ? There is no rule for that. – Andra Apr 17 '18 at 17:59

1 Answers1

1

The problem is that your rules don't match the ssl non-www urls, so the redirection from https://example.com to https://www.example.com isn't happening on your server. .

You can use the following generic rule to redirect your domains to https://www :

RewriteEngine on

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$
RewriteRule ^.*$ https://www.%1%{REQUEST_URI} [NE,L,R=301]

Make sure to clear your browser cache before testing these rules.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • 1
    mate! it it a beautiful and best rule ever! thank you a lot. All domains are redirected properly. awesome! resolved! – Astarot Apr 17 '18 at 21:15