我想将所有通配符子域重定向到https并制作如下的重写规则:
http://#.example.com => https://#.example.com => https://example.com/index.php?id=#
我有这段代码,但它没有用,而且我对语法不确定。
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]
答案 0 :(得分:1)
哟可以用一个RewriteRule
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$
RewriteRule ^/(.*)$ https://www.example.com/index.php?id=%1 [L,R]