将HTTP重定向到HTTPS并将WWW重定向到NON

编程入门 行业动态 更新时间:2024-10-19 17:33:26
本文介绍了将HTTP重定向到HTTPS并将WWW重定向到NON-WWW URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将所有HTTP请求重定向到HTTPS,并将所有www重定向到非www URL.

I'm trying to redirect all HTTP requests to HTTPS and all www to non-www URLs.

也就是说,

  • example 到 example
  • www.example 到 example
  • www.example 到 example
  • www.example 到 example
  • example to example
  • www.example to example
  • www.example to example
  • www.example to example
  • 我成功地能够重定向URL条件(1、2和3),但是第4个重定向条件不起作用,即 www.example 到 example .

    I was successfully able to redirect URL conditions (1, 2 & 3) but the 4th redirect condition does not work, i.e. www.example to example.

    我为我的网站的www和非www URL都具有SSL证书.我当前正在使用WordPress.

    I have an SSL certificate for both www and non-www URLs for my website. I'm currently using WordPress.

    我的.htaccess文件包含以下代码:

    My .htaccess file contains the following code:

    RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC] RewriteRule (.*) %1%{REQUEST_URI} [L,R=301]

    我尝试了许多不同的重定向条件,但是没有一个起作用.

    I've tried many different redirect conditions but none worked.

    我在Firefox中收到以下错误:

    I get the following error in Firefox:

    在连接到www.example时发生错误.对等方报告它遇到内部错误.错误代码:SSL_ERROR_INTERNAL_ERROR_ALERT

    An error occurred during a connection to www.example. Peer reports it experienced an internal error. Error code: SSL_ERROR_INTERNAL_ERROR_ALERT

    我该怎么做才能重定向第四个URL条件?

    What can I do to redirect the 4th URL condition?

    推荐答案

    我终于找到了解决问题的方法.是CloudFare,我使用的是免费版本.

    I finally found the solution to the problem. It is CloudFare, I was using the free version.

    通过Cpanel为我的网站关闭cloudfare可使所有重定向正常工作.

    Turning off cloudfare for my website from Cpanel made all the redirects work.

    更多推荐

    将HTTP重定向到HTTPS并将WWW重定向到NON

    本文发布于:2023-10-31 13:13:03,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1546186.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:重定向   并将   HTTP   WWW   HTTPS

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!