I specifically need an http to https redirect that works in curl, so I've been testing with "curl -IL http://support.example.com". HSTS is already enabled, so normal web browsers redirect without a 301/302 in place.
I have other redirects working in .htaccess, so I know the file is live. Same with /usr/local/apache/conf/includes/pre_virtualhost_global.conf - most things I do there work fine, it's only this redirect that's eluding me. This leads me to believe that I'm misunderstanding something, but I can't fire out what.
This works in pre_virtualhost_global.conf, but it's just to demonstrate that I can get a single redirect in that file to give me the curl output I'm looking for.
With that, I get the following output from curl:
This is what I need - a 302 with a location header, followed by a 200.
For the real redirect, I have:
The comments show some of the alternative syntax I've tried.
But no dice:
I have this working on another server (one without CPanel):
Any ideas?
I have other redirects working in .htaccess, so I know the file is live. Same with /usr/local/apache/conf/includes/pre_virtualhost_global.conf - most things I do there work fine, it's only this redirect that's eluding me. This leads me to believe that I'm misunderstanding something, but I can't fire out what.
This works in pre_virtualhost_global.conf, but it's just to demonstrate that I can get a single redirect in that file to give me the curl output I'm looking for.
Code:
Redirect 302 /foo https://support.example.com
Code:
T[mneedham@jelly:~/] curl -IL http://support.example.com/foo
HTTP/1.1 302 Found
Date: Wed, 13 Dec 2017 21:58:47 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Location: https://support.example.com
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 200 OK
Date: Wed, 13 Dec 2017 21:58:48 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
X-Powered-By: PHP/5.5.30
Vary: User-Agent
Content-Type: text/html
For the real redirect, I have:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
# RewriteCond %{HTTPS} !=on
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
# RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,R=302]
RewriteRule (.*) https://support.example.com%{REQUEST_URI} [R=302,L]
</IfModule>
But no dice:
Code:
T[mneedham@jelly:~/] curl -IL http://support.example.com/
HTTP/1.1 200 OK
Date: Wed, 13 Dec 2017 22:01:48 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
Last-Modified: Sat, 14 Nov 2015 04:20:43 GMT
ETag: "1c121-6f-524787fd69cc0"
Accept-Ranges: none
Content-Length: 111
Content-Type: text/html
Code:
T[mneedham@jelly:~/] curl -IL http://gamma.example.com/
HTTP/1.1 302 Found
Cache-Control: no-cache
Content-length: 0
Location: https://gamma.example.com/
Connection: close
HTTP/1.1 200 OK
Date: Wed, 13 Dec 2017 22:02:33 GMT
Server: Apache/2.2.3 (CentOS)
Strict-Transport-Security: max-age=0; includeSubdomains; preload
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Last-Modified: Mon, 13 Jun 2016 16:16:30 GMT
ETag: "3648051-247-36095380"
Accept-Ranges: bytes
Content-Length: 583
Content-Type: text/html; charset=UTF-8
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Option: SAMEORIGIN
Last edited by a moderator: