Redirect www to non-www in Dokku
Hey 👋,
recently I have been trying to figure out why my site was not ranking very well for my own name.
A friend of mine suggested to check my site in ahrefs.
I had a pretty decent ranking (92%)… but I saw something strange with my canonical url: I was not redirect www to non-www.
How to redirect www to non-www using Dokku
After a couple of quick Google searches the answer was not obvious.
Some places pointed to using some custom configuration for nginx. But the dokku’s documentation was a bit confusing for my taste.
But then I found an easier alternative: Dokku Redirect plugin.
As easy as sshing into my dokku server and doing:
- Installing the
dokku-redirect
plugin.
$ dokku plugin:install https://github.com/dokku/dokku-redirect.git
- Setting up the actual domain redirect for my app.
$ dokku redirect:set aaron.com.es www.aaron.com.es aaron.com.es 301
⚠️ Note: In the last command (above) the first
aaron.com.es
is the app name.
That’s it!
Now all my requests to www.aaron.com.es
redirect to aaron.com.es
🎉
Let’s see if that improves my ranking :)
Psst! If this short article was helpful to you let me know by clicking the like button below. It means a ton to me!