How to Change the Default Web Page that is Shown When Someone Goes to Your Domain Name

Set the Directory Index Page to Something Different


How to Change the Default Web Page that is Shown When Someone Goes to Your Domain Name

by Christopher Heng, thesitewizard.com

One of thesitewizard.com's visitors wrote to ask me how he could make a certain page the default web page that is displayed when his visitors go to his site's domain name. For example, he wanted his visitors to see the web page located at "http://www.example.com/home2.html" when they typed his domain name, http://www.example.com/. This article explains how this can be accomplished.

Before You Read On

The Easiest Way

If your web page is just a normal HTML file, like (say) "home2.html", the easiest way is to simply rename it to "index.html". Most (if not all) web servers will automatically serve that file when your visitors go to your domain without any filename (like "http://www.example.com/").

Using a standard name like "index.html" not only solves the problem, but it may also help when search engines discover that http://www.example.com/ has an identical page to http://www.example.com/index.html. Since this is the case for most websites, an intelligent search engine can simply regard it as the same page, and not treat it as a duplicate, causing all sorts of duplicate content problems.

This should be the method you use, unless you have special reasons for not wanting the standard filename.

How to Modify the Directory Index Filename on Apache Web Servers

For some people, the above method is not possible. For example, you may want http://www.example.com/ to invoke the http://www.example.com/special.php script instead of an ordinary web page.

If your site is hosted on an Apache server, you should create an text file using a plain ASCII or programmer's editor with the following line:

DirectoryIndex special.php

You should of course use the actual file name you want as the directory index instead of "special.php".

In addition, if you want (say) the web server to serve the "special.php" file by default, but if it's not present, to display the "index.html" file, do the following:

DirectoryIndex special.php index.html

You can add other filenames to that list if you wish. Separate each filename from the others with a space.

Some things to note:

Save the file as ".htaccess". If you use Notepad, be sure to include the quotation marks around the filename, or Notepad will add a .txt extension to your file without telling you. Notice that the name begins with a full stop (period) and is entirely in small letters (lowercase). Do not change the name.

Finally, upload the file to the top web directory of your website (the folder where you put the site's home page). Make sure that your FTP program uploads it in text mode, and not as a binary file.

Warnings

Conclusion

With the above steps, you have changed the name of the default web page for your domain when it is requested without an additional folder name or filename.

This article can be found at http://www.thesitewizard.com/apache/change-default-page-for-domain.shtml

Copyright © 2008-2012 by Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from http://www.thesitewizard.com/.

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to thesitewizard.com newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at http://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce this article in whole or part, in any form, without obtaining my written permission.

Related Articles

New Articles

Popular Articles

How to Link to This Page

It will appear on your page as:

How to Change the Default Web Page that is Shown When Someone Goes to Your Domain Name





Home
Donate
Contact Us
Link to Us
Topics
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Domains
Web Hosting
Blogging
JavaScripts
PHP
Perl / CGI
HTML
CSS
.htaccess / Apache
Newsletters
General
Seasonal
Reviews
FAQs
Wizards

 

 
Free webmasters and programmers resources, scripts and tutorials
 
HowtoHaven.com: Free How-To Guides
 
Site Design Tips at thesitewizard.com
Find this site useful?
Please link to us.