How to Set website pages through the. htaccess File

Source: Internet
Author: User

Hello everyone, I'm kiness from Hunan. After a website is created, many new webmasters will be troubled by the default homepage settings of the website. For example, php programs are used, and the default homepage is mostly the "/index. php "file; if it is a program developed in asp, the homepage is opened by default."/index. asp. jsp. Of course, the spatial control panel of a few spatial vendors can support custom spatial pages, but most of them are still not supported. We all know that static pages are good for SEO, but many webmasters do not know how to set them. This article is a close-up article for your reference.

First, it is easy for everyone to understand. Take your website as an example. Figure 1:

  

 

Obviously, index. php is enabled on the homepage by default. In addition, the default homepage is "index. php", but the Suffix in the figure is not displayed in the URL bar. Contains files such as "or index.shtml. If no, it indicates that the "index. php" file is opened. If yes, check whether the content on the homepage is consistent with that on the homepage. If they are inconsistent, the "index. php" file is opened by default.

Next, I will introduce how to set the default static page for a website in the. htaccess file. First, copy the following code:

<Files ~ "^. (Htaccess | htpasswd) $">
Deny from all
</Files>
DirectoryIndex index.html index. php
Order deny, allow

The code above indicates the order in which files under the root directory are opened by the website by default. "Index.html" is the first line. If this file is not available, open "index. php ". If the website is developed using asp, the code can be set as follows:

<Files ~ "^. (Htaccess | htpasswd) $">
Deny from all
</Files>
DirectoryIndex index.html index. asp
Order deny, allow

When no index.html file exists in the directory, the "index. asp" file is opened by default.

If you are a new webmaster and do not know the development environment of your website, and want to set the default to open static files, you can directly use 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

Dependencies, index. jsp, and index. aspx.

Copy the corresponding code, paste it to notepad, and save it as a ". htaccess" file. Then upload the file to a directory on the website through FTP. If the file ". htaccess" is not supported during storage, you can upload the file to a directory and change it to The. htaccess file name.

This article by Hunan push (original http://www.hntui.com/jingyan/32.html) Webmaster kiness original. Please indicate the source for reprinting. Thank you!

Related Article

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.