Hi Paul,
I'm not an expert at this but I did notice some things.
On Sat, Jul 09, 2022 at 10:31:41AM +0000, Paul Lewis via BitFolk Users wrote:
Just reducing this to an example of behaviour you want vs behaviour
you don't want…
All the VirtualHosts are configured the same, and look
like this:
<VirtualHost *:80>
DocumentRoot /var/www/savouredescapes
ServerName
www.savouredescapes.com
ServerAlias
savouredescapes.com origin-www.savouredescapes.com
www-test.savouredescapes.com
<Directory /var/www/savouredescapes/>
AllowOverride All
</Directory>
ErrorDocument 403 /error/noindex.html
ErrorLog ${APACHE_LOG_DIR}/savouredescapes-error.log
CustomLog ${APACHE_LOG_DIR}/savouredescapes-access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =savouredescapes.com [OR]
RewriteCond %{SERVER_NAME} =origin-www.savouredescapes.com [OR]
RewriteCond %{SERVER_NAME} =www.savouredescapes.com [OR]
RewriteCond %{SERVER_NAME} =www-test.savouredescapes.com
RewriteRule ^
https://www.savouredescapes.com%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
The first thing that strikes me is that this virtualhost is only for
port 80. Port 443 (https) connections aren't going to hit this vhost
at all, I don't think. Where do port 443 connections go?
The other thing I notice is that when I do:
$ curl -s -v
https://origin-www.wofeckcsclub.co.uk > /dev/null
I see:
GET / HTTP/1.1
Host: origin-www.wofeckcsclub.co.uk
User-Agent: curl/7.64.0
Accept: */*
[…]
< HTTP/1.1 301 Moved Permanently
< Date: Sat, 09 Jul 2022 11:46:41 GMT
< Server: Apache/2.4.29 (Ubuntu)
< X-Redirect-By: WordPress
< Location:
https://www.wofeckcsclub.co.uk/
Whereas with
$ curl -s -v
https://origin-www.savouredescapes.com/ > /dev/null
GET / HTTP/1.1
Host:
origin-www.savouredescapes.com
User-Agent: curl/7.64.0
Accept: */*
[…]
< HTTP/1.1 200 OK
< Date: Sat, 09 Jul 2022 11:49:12 GMT
< Server: Apache/2.4.29 (Ubuntu)
< Link: <https://www.savouredescapes.com/wp-json/>;
rel="https://api.w.org/"
< Link: <https://wp.me/7loaj>; rel=shortlink
< Vary: Accept-Encoding
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
etc. it serves a web page, no redirect by Wordpress.
So I think maybe there is some setting different in Wordpress
between your two example sites.
Note that even your working example doesn't redirect by your Apache
config, it redirects by Wordpress.
Also I am guessing there is actually more to your config otherwise
what is the point of all the additional names? I assume you're
recognising Cloudfront by some means and not redirecting them back
on themselves infinitely and by the same token your "test" URIs
presumably don't redirect (intentionally) for you when you are
testing them.
Cheers,
Andy
--
https://bitfolk.com/ -- No-nonsense VPS hosting