【问题标题】:How to redirect http to https url in nginx?如何在 nginx 中将 http 重定向到 https url?
【发布时间】:2016-06-22 17:15:27
【问题描述】:

我们的服务器上有很多域,但我们想将一些域 http 永久重定向到 https 。 喜欢我们的域名

http://example.com/         //main public folder
http://example.com/member   //member folder
http://example.com/online   //online folder folder

请告诉我这些域的具体规则是什么

【问题讨论】:

    标签: .htaccess nginx


    【解决方案1】:

    在你的 .htaccess 中使用它:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
    

    这将在所有内容上强制使用 https。如果您想对特定文件夹执行此操作,请使用:

    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteCond %{REQUEST_URI} folder 
    RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]
    

    【讨论】:

    • 能说一下nginx会如何使用.htaccess配置吗?
    猜你喜欢
    • 1970-01-01
    • 2022-08-14
    • 2011-03-29
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 2020-08-07
    相关资源
    最近更新 更多