On how to set the default page of a Web site through the. htaccess file

Source: Internet
Author: User
Keywords SEO

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Hello everybody, I am the kiness of Hunan push. Site new good, many novice webmaster will be the site's default home page settings is very annoying. For example, using the PHP program, the default home page is mostly open the root of the Web site inside the "/index.php" file, if the development of ASP language programs, the first open most of the default open "/index.asp"; Index.jsp "and so on. Of course, the Space Control Panel of a few space vendors can support custom default pages, but most of them are still not supported. We all know that the use of static pages conducive to SEO, but many webmasters do not know how to set. So small series close-up this article, for you have the need for webmaster reference.

First of all, it is easy to understand. To small series of their own website for example, figure I:

  

Obviously, the site is the home page default open is index.php. There is also a, the first page by default open is "index.php", but the URL bar will not show the suffix in the diagram. This situation, the PHP language Web site Procedures for example, a very simple way to distinguish is to look at the site root directory there is no static "index.html" or "index.shtml" and other documents. If none, the opening is "index.php" file. If so, check to see if it is consistent with the homepage content of the website. If inconsistent, it is the "index.php" file that is opened by default.

Next small series on the introduction of the. htaccess file to set the Web site default open static Page method. First copy the following code:

<files ~ "^. (HTACCESS|HTPASSWD) $ ">


deny from all


</Files>


directoryindex index.html index.php


Order Deny,allow

The code above means that the Web site defaults to open the order of files in the root directory. The first is "index.html", if there is no such file, then open "index.php". If you are developing a Web site in ASP language, the code can be set as follows:

<files ~ "^. (HTACCESS|HTPASSWD) $ >
Deny from all
</Files>
DirectoryIndex index.html index.asp
Order Deny,allow

The "index.asp" file is opened by default when there is no "index.html" file in the directory.

If it is a novice webmaster, do not know their own site development environment, and want to set the default open static file, you can consider directly using the following code.

<files ~ "^. (HTACCESS|HTPASSWD) $ >
Deny from all
</Files>
DirectoryIndex index.html index.php index.asp index.shtml index.htm index.jsp index.aspx
Deny,allow

The meaning of the code is roughly similar to the above, set the default open Web site directory in the order of the files are index.html, index.php, index.asp, index.shtml, index.htm, index.jsp, index.aspx.

Depending on your needs, copy the appropriate code, paste it into Notepad, and save it as a ". htaccess" file. Then upload the Web site via FTP to the more directory. If you are saving with a ". htaccess" file name, you can upload the file to a more directory and change to the. htaccess file name.

This article by Hunan push (original http://www.hntui.com/jingyan/32.html) stationmaster kiness original. Reprint please be sure to indicate the source, the niche will be greatly appreciated, thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.