Simple Domain Redirect : WordPress Plugin
So I’m one of those people that likes buying up domain names. I’m constantly finding a domain name that I like and adding it to the collection. One thing that has always bothered me is any of those domains could be used to load my site. Once a page has loaded and a link is clicked, it usually will correct the URL to the primary domain that I prefer to use for the site. Let me give you an example.
Someone could go to http://briehl.com and the blog would load as expected. However, I don’t want all my extra domain names floating out there to be picked up by Google, Bing, etc. I only want one domain associated with my site. After someone clicks on a link, the URL would update to http://jonathanbriehl.com/whatever. That’s all well and fine, but I really wanted to try to prevent the initial http://briehl.com from loading.
I’ve been doing something similar in a number of projects for years. Today I finally decided enough is enough and wrote a quick and simple little WordPress plugin to take care of the problem. When activated, the plugin simply takes the URL from the WordPress settings and compares it to the URL used to call up the page. If they are different, it returns a 301 redirect and then loads the page with the proper URL.
So, if you were to load this post with the following URL …
… a 301 redirect would be returned and the site would reload with the following URL.
Ok – so this post now has about 10 times the number of lines that the plugin even has, so I’ll end here. Questions, suggestions – let me know!
Download the Simple Domain Redirect WordPress plugin
Warning: The plugin should be totally safe to try, but I always encourage people to test everything before throwing it into a live environment. Use at your own risk. If you’re not comfortable attempting these, don’t do it. I don’t want to get any “you ruined my site and destroyed my business” comments.