Hello what should add to htaccess to redirect all subdomains to https for example webmail.example.com?
<IfModule mod_rewrite.c>
RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
Header set content-Security-Policy: upgrade-insecure-requests
CodePudding user response:
RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
You already have a rule that redirects everything (any domain/subdomain) to HTTPS. So if this is not working then either:
This subdomain is not pointing to the same area of the filesystem (so this
.htaccess
file does not apply and the directives are ignored).These directives are not doing anything, ie. mod_rewrite or
.htaccess
overrides are not enabled on your server.
Since you have a "front-controller" pattern in the .htaccess
file (the last rule), I assume this is being used successfully to serve your website? If so then .htaccess
and mod_rewrite would appear to be enabled and working.
That would seem to leave #1.
In which case is the webmail
subdomain pointing to this area of the filesystem?
Is the webmail
subdomain something that you've created or is this part of your hosting account? webmail
is a common subdomain that cPanel uses (and you have tagged your question cPanel
). In which case, this subdomain likely points to an entirely different area of the filesystem and is out of your control.