Prevent the subdomain from being redirected to the main domain

0

I have created a subdomain es.domain.es but when I enter it in the address bar it takes me to dominio.es

My .htaccess file is:

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://dominio.es/$1 [R=301,L]

I got the ones from 1and1 to redirect http to https. I tried to delete it but it keeps redirecting. I have searched everywhere but I am unable to solve it.

Thank you very much!

    
asked by matsrom 14.06.2018 в 11:24
source

2 answers

0
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/%{REQUEST_URI} [L,R=301]
    
answered by 14.06.2018 / 15:06
source
0

When the request comes through port 80 (usually http)

RewriteCond %{SERVER_PORT} 80

You redirect it explicitly to apex (dominio.es)

RewriteRule ^(.*)$ https://dominio.es/$1 [R=301,L]

With which you overlook the subdomain

The redirect rule should be:

RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This is: if the request is not via https (whatever the port is), you redirect it to the same url but with https , keeping the host instead of forcing the apex. p>     

answered by 14.06.2018 в 15:08