【问题标题】:Redirect wildcard subdomains to https将通配符子域重定向到 https
【发布时间】:2018-10-22 22:26:28
【问题描述】:

我想将所有通配符子域重定向到 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]

【问题讨论】:

  • 用户页面:http://#.example.com => https://#.example.com 服务器:https://#.example.com like https://example.com/index.php?id=#

标签: php .htaccess ssl mod-rewrite


【解决方案1】:

你可以用一个RewriteRule做到这一点

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$
RewriteRule ^/(.*)$    https://www.example.com/index.php?id=%1 [L,R]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-12
    • 1970-01-01
    • 2019-01-23
    • 2018-08-10
    • 2018-12-10
    • 2014-05-29
    • 2012-07-08
    • 1970-01-01
    相关资源
    最近更新 更多