The problem is the following: I have the host http://www.midominio.cl
that through a routine .htaccess
, in the public, is redirected to https://www.midominio.cl
So far so good. The problem arises that, with the attached routine, it redirects everything including subdomains and additional domains that do not have the SSL certificate. The idea is: Only redirect from http to https , midominio.cl
and its dependencies and not to consultora.midominio.cl
or another folder where you have an addon domain. I've also tried including a PHP routine in the subdomain's index header but obviously I get a redirect loop.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^midominio\.cl$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
// hasta aquí funciona la redirección de hhtp a https //
// Las siguientes líneas no funcionan //
RewriteCond %{HTTP_HOST} ^consultora.midominio\.cl [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I searched on stackoverflow.com and there is a similar query whose answer didn't work (or I couldn't understand it). [ https://stackoverflow.com/questions/17715724/modrewrite-rewritecond-to-turn-off-ssl-redirect-for-a-certain-requested-url ]
Well, the help is appreciated.
Update.
I was able to prevent the redirect to a subdomain with the following line
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !=subdominio.midominio.cl #Nueva línea
RewriteCond %{HTTP_HOST} !^midominio\.cl$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
But I still can't avoid the redirection to a otrodominio.cl
parked one.
Well today I had some time to solve this and I realized that the solution was easier than it seemed.
Case closed. I leave the answer in case it helps someone.