我知道很多人的问题与这个问题基本相同。但是,我显然无法理解网络上试图为我解释情况的答案和数以千计的博客条目。
我有一台运行 Ubuntu 18.04 的服务器,由 1and1 和 Apache 2.4.29 托管。该服务器的唯一目的是托管 wordpress。wordpress 是唯一且可访问的,但是我需要在我想要避免的 url 前面指定 www 标签。这是我目前的重定向情况:
#### Working:
$ curl -I https://www.mywebsite.org
HTTP/1.1 200 OK
Date: Fri, 24 May 2019 07:36:42 GMT
Server: Apache/2.4.29 (Ubuntu)
Link: <https://www.mywebsite.org/wp-json/>; rel="https://api.w.org/"
Content-Type: text/html; charset=UTF-8
$ curl -I http://www.mywebsite.org
HTTP/1.1 301 Moved Permanently
Date: Fri, 24 May 2019 07:37:23 GMT
Server: Apache/2.4.29 (Ubuntu)
Location: https://www.mywebsite.org/
Content-Type: text/html; charset=iso-8859-1
$ curl -I www.mywebsite.org
HTTP/1.1 301 Moved Permanently
Date: Fri, 24 May 2019 07:36:56 GMT
Server: …Run Code Online (Sandbox Code Playgroud) apache-2.4 ×1