======================
== fabulous.systems ==
======================
Welcome to the world of fabulous.systems

apache2: Redirect multiple domains to the same website

#modern-stuff #sysops #linux #apache

Over the last couple of years, I aquired a nice collection of various domains. Since I only keep them for historical purposes, I decided to redirect all domains to this blog domain. Usually, you can achieve such a redirection by simply pointing all your domains to the same virtual host within your web server configuration in case you are using WordPress. However, this won’t work when using some caching plugins. Some .htaccess magic will help though.

The following .htaccess snippet redirects every domain that’s not called www.targetdomain.com to the - well - desired target domain:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.targetdomain.com
RewriteRule (.*) https://www.targetdomain.com/$1 [R=permanent,QSA,L]

The redirection also works for all queries - https://olddomain.com/foo will always redirect to https://www.targetdomain.com/foo.

Do you have any comments or suggestions regarding this article? Please drop an e-mail to feedback@fabulous.systems!