【问题标题】:Redirecting in website using .htaccess使用 .htaccess 在网站中重定向
【发布时间】:2015-06-08 11:05:10
【问题描述】:

谁能帮助我如何将所有http://example.comhttp://www.example.com 重定向到https://www.example.com。我最近为我的网站购买了一个 ssl,因此需要重定向它。使用 .htaccess 重定向对我来说会更有用。提前致谢。

【问题讨论】:

标签: .htaccess web redirect


【解决方案1】:

那里有很多解决方案。这是直接处理此问题的 apache wiki 的链接。

http://wiki.apache.org/httpd/RewriteHTTPToHTTPS

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*)$ https://www.example.com/$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

【讨论】:

    猜你喜欢
    • 2015-10-22
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 2017-01-28
    • 2022-08-02
    • 2013-06-04
    相关资源
    最近更新 更多