Answer the question
In order to leave comments, you need to log in
How to implement dynamic subdomains for https only?
How to implement redirect from http to https and use mod_rewrite rule for https only? Works separately.
This type of redirect:
http://demo.example.com => https://demo.example.com
https://demo.example.com => https://example.com/index.php?id=demo
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^(.{2,})\.example.com$
RewriteRule (.*) https://example.com/index.php?id=%1 [P,L]
Answer the question
In order to leave comments, you need to log in
1. I've painted a bunch of examples here, you should go.
https://klondike-studio.ru/standards/standartnyy-h...
Also, you forgot to add a condition to the second rule, do not forget that there can be several conds in a row.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(.{2,})\.example.com$
RewriteRule (.*) https://example.com/index.php?id=%1 [P,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question