The solution to this was permanent redirects.4 Usually I would want to do something like this at the server level (in nginx or Apache), but on this particular occasion there were a few reasons I wanted to avoid doing it this way.
As this domain's DNS records were already managed by Cloudflare, it was the next logical step to make use of their Page Rules, which I've never needed to use before.
I've always found Cloudflare's documentation to be pretty decent on the whole, but in this instance I didn't even need to go to the docs! Cloudflare have a short tutorial on this exact topic.5
When I initially went to the 'Redirect Rules' portion in the dashboard, I was confronted by a few dropdown menus. These can be ignored in favour of their expression editor, so I lifted the example expression from the tutorial. (Copy and paste often tends to be the solution 😜). I did have a wee read through their documentation on expressions as it seems a useful feature, with lots of scope for more complex scenarios.
In this case, the expressions were simple: when inbound requests match this expression (http.request.full_uri contains "www.operadeilumi.org.uk"), then create a response using the following settings:
TYPE: Dynamic
EXPRESSION: concat(
"https://",
"operadeilumi.org.uk",
http.request.uri.path
)
STATUS CODE: 301The http.request.uri.path handles the relative path that follows the domain (for example, the about page is located at /about), so any traffic targetting specific pages will still land on the page they were aiming for. One could probably just join the first two segments (https:// and operadeilumi.org.uk), but it seemed neater and more sensible to have the expression handle the protocol, domain and URI path explicitly.
After saving that rule, I tried Seobility's redirect checking tool for checking redirects in more depth and without the SEO stuff. This checks the following four variations of your domain:
https://www.example.comhttps://example.comhttp://www.example.comhttp://example.com
If they all resolve to the same domain (https://example.com, for example, though the desired target can be specified by the user), then happy days - I've managed to correctly establish a canonical URL.
This process probably took no more than 5 minutes. After about a month like this, I've noticed search engines now only serve a single result per URI. The privacy-respecting analytics tool used on ODL's site now only displays visitors on each page once, instead of one each for www and non-www viewers.
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.