Fun with mod_rewrite and subdomains
Intercepting and redirecting foo.freso.dk to freso.dk while still leaving bar.freso.dk be (for the rare occasion you don't want to visit the pub instead).
Being a fan of the "www. is deprecated" movement, I obviously couldn't be satisfied with the library being accessible from both freso.dk and www.freso.dk, so I went and commented out and edited the lines for redirecting www.(domain) to (domain) in Drupal's default .htaccess file.
However, I also realised that due to the way I've set up the DNS (look up the A record(s)), spam.freso.dk, eggs.freso.dk, ham.freso.dk, etc. would all just sit there like www.freso.dk did just moments ago. I couldn't just redirect all subdomains either, as the way I have and am doing development of this site (which is an entry in its own right, I'd say), requires me to have four domains - freso.dk and three subdomains. And as they're all running the same codebase, redirecting all subdomains would lead to my test and development sites breaking. :( After playing around some though, I figured out the key was in first excluding the subdomains I didn't want to redirect, and then throw in everything else (".*
"): RewriteCond %{HTTP_HOST} !^(sub1|sub2|subN)\.freso\.dk$ [NC]<br> RewriteCond %{HTTP_HOST} ^(.*)\.freso\.dk$ [NC]<br> RewriteRule ^(.*)$ http://freso.dk/$1 [L,R=301]
(Which reminds me that I should probably fetch and install some module with a code formatting filter...)
Go ahead and test it. Apart from three subdomains, everything should send you back to the main domain. :)