After my article describing what a .htaccess file is and how it can be used to help your own Web development, I received dozens of E-mails on the subject. It has been one of the most popular topics I have covered for 2005 so far. Of all of them I have plowed through so far, my exchange with Randy (a loyal Lockergnome fan) has been most enlightening.
I enjoyed reading your article on htaccess files. (FWIW, I obtained the article link through one of Lockergnome’s daily newsletters.) Learning more about this file’s functionality actually can address a temporary need of mine. I have several domains parked under my active domain’s ip address. At some point, one or more of these domains will have a unique ip address assigned. Until the site(s) go live, parking the domains saves some cash; I would like to use the htaccess file to redirect visitors to a custom page which describes the project’s scope and provides a tentative “go live date.”
(Essentially, a customized under construction page.) Can you point me to an article or resource which will provide me some specifics as to what changes need to be made in the primary domain’s htaccess file to accomplish this redirection (the file already exists in the domain’s root directory)? Also, I have perfectly legitimate business reasons for wanting to make these changes but don’t want to be penalized by search engine spiders for making these changes. Are there any issues along these lines which I should be aware of before proceeding?
First off, I thanked him for the kind words, and then I suggested two options that I knew of right off the top of my head. The first was creating the redirects for the domain names through the .htaccess file itself. The Javascript Kit Web site has a good article on how to do this and how to make it as painless as possible.
The second thing I suggested was trying to tackle the problem with the domain name register. Depending on who your domain name register is, you might be able to do this on their end. Some domain name registers allow you to specify where your domain name is pointing exactly. Since you are running your Web page off the IP address currently, you could tell them to go to:
http://123.456.789/testsite/index.html
Then when your ready for the Web site to go live, just change it with them. The only problem there would be waiting for the domain names to propagate, which could mean it would be 24 to 72 hours before you started seeing any results.
Randy read through my solutions, and to his credit came up with an even better one.
Not being one to throw in the towel on what I thought would be a reasonably simple exercise, I did some further research and found the following code snippet:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(ww+\.)?parked-domain\.com
RewriteCond %{REQUEST_URI} !/parked-domain/
RewriteRule ^(.*)$ /redirect-folder/$1 [L]
RewriteCond %{HTTP_HOST} ^(ww+\.)?second-parked-domain\.com
RewriteCond %{REQUEST_URI} !/second-parked-domain/
RewriteRule ^(.*)$ /redirect-folder-2/$1 [L]
Adding this code to the global .htaccess file works flawlessly for me. As you can see, there is no problem writing additional conditions to cover multiple parked domains should the need arise. (I have tried this code with two parked domains and the code works as “advertised.” Now I don’t have any excuse for not posting the professional, information filled, under development pages, which initially spurred my interest in this area.
There you have it, three ways you can choose from to solve an easy problem. Remember if you have any other tough Web development or Web hosting questions, send them my way! I’m always looking to help a few people out with the many Web site problems there are out there today.
Also if you enjoy what you see here, see how you would like it in audio form! I am still looking for feedback and responce to my first attempt at Internet broadcasting through my own Web hosting radio show. Thanks!







Comments are closed.