Addressing Canonical URLs WWW with and without on NGinx
If you do an SEO analysis of your page the analysis tool might complain about canonical URLs with regards to WWW and without. Learn more about that here.
When looking at typical Forge NGinx server configuration data, you will see the top of your config:
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/eugene.fintechsystems.net/before/*;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name eugene.fintechsystems.net;
server_tokens off;
root /home/forge/eugene.fintechsystems.net/public;
This is all fine and dandy, but what if your SEO tool moans about WWW canonical URLs?
Actually the fix is simple.
Click Edit Files, then Edit Nginx Configuration, then do this:
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/eugene.fintechsystems.net/before/*;
server {
server_name www.eugene.fintechsystems.net;
return 301 https://eugene.fintechsystems.net$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name eugene.fintechsystems.net;
server_tokens off;
root /home/forge/eugene.fintechsystems.net/public;
Finally, don't forget to update your DNS with the new record.
Updated: 2 years ago