Using PHP to build station experience

Source: Internet
Author: User

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

Recently using php+ MySQL space to do the station www.kingwq.cn, first found a problem, the program is listed, depressed on the occasion to consult our foreign teacher, GG, found to be. htaccess file, summed up the online for the. htaccess file detailed introduction. Now share with you.

If the site is listed in the directory, create a file. htaccess file in the root directory of the site.

Create a. htaccess file now create a local random text document, and then write the following command in the document, upload to the FTP space, in the FTP space renamed on the line.

Use the method to record:

Files that list directories are blocked.

Sometimes when a user enters a directory in a browser, all the files in the directory are listed, which is clearly a security risk. To not allow the file to be listed, you can add the following command to the. htaccess file: options-indexes

Allow/mask specific IP addresses.

Sometimes you want to allow or block access to a particular directory by a specific IP address, either by using the deny from 000.000.000.000 or allow from 000.000.000.000. To block all IP addresses with deny from all.

Specifies a different index file.

If you are using PHP to develop your site, then your home page file may be index.php, to let index.php as the default homepage of the site, with the command: DirectoryIndex index.php index.php3 Index.html index.htm. Server or from the right to check whether there is this file in the directory, if found, the file as the default home page.

Steering (redirection)

A. htaccess file is best used to turn any request to a different directory, file (even if the file, directory is not on the same server).

Redirect/olddirectory http://www.newsite.com/newdirectory.

Custom error page.

With the. htaccess file, you can also point to the various error message pages of the server to your own pages. For example, the file is not found is 404 error, with the following command can point to the 404 error to their own customized notfound.html.,errordocument 404/notfound.html.

Frequently occurring error message codes:

401-authorization Required (Unauthorized)

400-bad request (wrong requests)

403-forbidden (Forbidden)

500-internal Server error (server internal error)

404-wrong page (file not found)

The configuration directive in the. htaccess file acts on the directory where the. htaccess file resides and all of its subdirectories, but it is important to remember that the more advanced directory may also have a. htaccess file, and the instructions are in the order of lookup, so The instructions in the. htaccess file in a particular directory may overwrite the instructions for the. htaccess file in its more advanced directory, that is, the instructions in the subdirectory will overwrite the instructions in the higher-level directory or the primary server configuration file.

[Tags]htaccess,tutorial[/tags]

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.