@Vinko
For your general approach, I'm not sure why you decided to limit the length of the TLD in your regular expression? This is not a very secure future, and I'm not sure what benefit it provides? This is actually not even “now proof”, because there is at least one 6-digit TLD (.museum) that will not match.
It seems unnecessary to do this. Could you just do ^[^.]+\.[^.]\+$ ? (note: the question mark is part of the sentence, not a regular expression!)
All aside, there is a big problem with this approach: it will fail for domains that are not directly under the TLD. These are domains in Australia, the UK, Japan, and many other countries that have hierarchies: .co.jp, .co.uk, .com.au, etc.
Regardless of whether this applies to the OP, I do not know, but this is what you need to know if you answer “fix everything” after the answer.
The OP has not yet made it clear whether he wants a universal solution or a solution for one (or a small group) of known domains. If this is the latter, see My other note on using the Zigdon approach. If this is the first, then proceed to the Vinko approach, given the information in this post.
Edit: One thing that I still have left so far, which may or may not be a business option for you, is to go the other way. All our sites redirect http://www.domain.com to http://domain.com . People at http://no-www.org make a pretty good case (IMHO) because this is the "right" way to do it, but it's still just a matter of preference. One thing is certain, but it’s much easier to write a general rule for such a redirect than that.
org 0100h
source share