我正在尝试在.htaccess
文件中进行一些重定向。
以下是规则:
RewriteRule ^foo/bar$ https://www.my-website.dev/foooo/bar [L,R=301]
问题是,重定向导致http://www.my-website.dev/foooo/bar
。然后到https://www.my-website.dev/foooo/bar
。这比我想要的要多1个。
什么可能导致这种行为?
GET https://www.my-website.dev/foo/bar
GET http://www.my-website.dev/foooo/bar ==> I don't want this step
GET https://www.my-website.dev/foooo/bar
编辑:当我使用CURL时有些奇怪的结果:
$ curl https://www.my-website.dev/foo/bar -v
* Trying XX.XX.XXX.XX...
* TCP_NODELAY set
* Connected to www.my-website.dev (XX.XX.XXX.XX) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: www.my-website.dev
* Server certificate: Gandi Standard SSL CA 2
* Server certificate: USERTrust RSA Certification Authority
> GET /foo/bar HTTP/1.1
> Host: www.my-website.dev
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Age: 66
< Content-Type: text/html; charset=iso-8859-1
< Date: Wed, 28 Jun 2017 13:53:37 GMT
< Location: http://www.my-website.dev/foooo/bar
< Server: Apache/2.4.7 (Ubuntu)
< Via: 1.1 varnish-v4
< X-Varnish: 1449752 467271
< X-Varnish-Cache: HIT
< Content-Length: 388
< Connection: keep-alive
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://www.my-website.dev/foooo/bar">here</a>.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at www.my-website.dev Port 8080</address>
</body></html>
* Curl_http_done: called premature == 0
* Connection #0 to host www.my-website.dev left intact
正如您在正文中所看到的,我得到了正确的网址:<p>The document has moved <a href="https://www.my-website.dev/foooo/bar">here</a>.</p>
然而,在Location
标题中,错误的是......