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.
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