. htaccess file Detailed Introduction

Source: Internet
Author: User
Tags password protection

    • understanding. htaccess Files , The following information from Baidu .

The. htaccess file (or "distributed Profile", which is its Chinese name) provides a way to configure a directory change by placing a file containing one or more instructions in a particular document directory to act on this directory and all its subdirectories. As a user, the commands you can use are limited. The administrator can set it through Apache's allowoverride instructions.

    • the role of the. htaccess file .

As an overview, the htaccess file is a configuration file in the Apache server that is responsible for the Web page configuration under the relevant directory.

Htaccess can help us implement include: folder password protection, user Auto Redirect, custom error page, change your file extension, block specific IP address of the user, only allow specific IP address of the user, prohibit directory list, and use other files as index file and other functions.

The next introduction is handwritten. htaccess files, but there are tools that can be automatically written here, Baidu: Rewriting-tool

First place a. htaccess file under the directory or file you need to control:

    

Open this file and start writing code:) Warm tip: #号代表单行注释, because the configuration of this file needs to have some regular knowledge, so please do your own brain repair.

     # turns the rewrite engine on or off, off means off, and once rewriteengine off then the rewrite does not take effect.

     Rewriteengine on

# matches the domain name you are currently accessing: the domain name format is www.xxx.com, the following means, as long as the input xxx.com or input www.xxx.com can access to our site

#%{http_host} indicates the domain name currently being accessed, ^ and \. And? and $ are regular symbols.

Rewritecond%{http_host} ^ (www\.)? xxx\.com$

    

     

. htaccess file Detailed Introduction

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.