Balu's Logo

Oops: To WWW or Not to WWW?

, — 1 minute to read

While relaunching this website I forgot to add a redirect from www.b-a-l-u.de to b-a-l-u.de. And none of you reminded me… :-).

This can not only result in issues with search engines with regards to duplicate content (keyword “canonical URLs”), but will also mess with the Content-Security-Policy and Cross-Origin-Resource-Policy if your site generator creates absolute links.

Guess how I found out…

I was quite confused because from one day to the other the site suddenly failed to load some of the extra ressources and images. And all of this just happened, because I randomly used www.b-a-l-u.de as the hostname.

Thankfully a simple redirect fixed things.

    RewriteEngine On

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^b-a-l-u\.de
    RewriteRule (.*) https://b-a-l-u.de/$1 [R=301,L]