【问题标题】:Apache HTTPS URL RewriteApache HTTPS URL 重写
【发布时间】:2018-02-20 05:30:43
【问题描述】:

我刚开始使用 Linux 和 Apache,却陷入了困境。

我有这个重写规则工作正常:

RewriteEngine on
RedirectMatch ^/$ /myserver/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myserver/ [R]

如何应用这些相同的规则重定向到https

谢谢!

【问题讨论】:

    标签: linux apache ubuntu mod-rewrite url-rewriting


    【解决方案1】:

    On the Apache wiki:

    RewriteCond %{HTTPS} !=on
    # This checks to make sure the connection is not already HTTPS
    
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
    # This rule will redirect users from their original location, to the same location but using HTTPS.
    # i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
    # The leading slash is made optional so that this will work either in httpd.conf
    # or .htaccess context
    

    如果我正确理解您的问题,您可以在您的具体示例中实现这一点。

    请注意,建议在您的非安全虚拟主机中使用重定向到您的安全虚拟主机。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-28
      • 1970-01-01
      • 2010-10-30
      • 2013-01-22
      • 2016-06-30
      • 1970-01-01
      相关资源
      最近更新 更多