. htaccess directory pseudo static rules and directory exclusions

Source: Internet
Author: User

Working principle

The. htaccess file (or distributed configuration file) provides a way to change the configuration for each directory by placing a file containing instructions in a specific directory with instructions for this directory and all of its subdirectories.
Description
If you need to use a filename other than. htaccess, you can change it with the Accessfilename directive. For example, if you need to use. config, you can configure it in the server configuration file in the following ways:
Accessfilename. config
Typically, the. htaccess file uses the same configuration syntax as the primary configuration file. The allowoverride directive determines, by category, which instructions in the. htaccess file are valid. If an instruction is allowed to be used in. htaccess, then in the description of this manual there is an overlay segment that describes the value that must be set in the allowoverride directive for this instruction to take effect.

Recently encountered some problems in the pseudo-static of. Htaccess, the following is a note of the questions encountered and the solution:

1..htaccess pseudo-Static rule formulation

# root folder access pseudo static to Cunfang1


Rewriterule ^ ([a-z0-9a-z_\-]+) (/) $/cunfang1/$1/[L]


The above rules can have all access to the folder under the root directory of the Web site, pseudo static to the corresponding folder under Cunfang1.

2. Exclude certain directories, so that the first rule can not be useful, such as the site root directory of/data,/images and so on.

# root directory folder access exclusion rule


Rewritecond $!^ (data|images|otherthings)


You can implement the specified directory exclusion functionality by placing the above code before the first rule.

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.