. htaccess syntax Parameter Description _php tutorial

Source: Internet
Author: User
Tags deprecated php source code
Have contacted the. htaccess file friends are the opposite of some of the syntax is not very understanding, often see a rule behind some of the uppercase L NC R QSA What, know what they mean? OK, the following article is simply a simple explanation of the relevant syntax parameters for the. htaccess file.

chain| C (link next rule)

This tag links the current rule to the next rule. It produces this effect: if a rule is matched, it continues to process its successor, that is, the tag does not work, and if the rule is not matched, its successor rule is skipped. For example, when performing an external redirect in a directory-level rule, you may need to delete ". www" (". www" should not appear here).

cookie|co=name:val:domain[:lifetime[:p Ath]] (set cookies)

Set a cookie on the client. The name of the cookie is "name" and the value is Val. Domains are the domain of the cookie, such as. apache.org, the optional lifetime is the lifetime of the cookie (in minutes), and the optional path is the cookie.

env| E=var:val (setting environment variables)

This tag will have an environment variable var value of Val,val that can contain extensible regular expression inverse references ($N and%n). This tag can be used multiple times to set multiple variables. These variables can be referenced indirectly in many subsequent cases, usually in Xssi ( ) or CGI ($ENV {VAR}), or through%{env:var} in the Condpattern parameter of subsequent rewritecond directives. Use it to remember the information that is stripped from the URL.

forbidden| F (Enforce Forbidden URL)

Forces the current URL to be suppressed, that is, to immediately respond to an HTTP response code of 403 (forbidden). With this tag, you can link several rewriteconds to conditionally block certain URLs.

gone| G (mandatory deprecated URL)

Forces the current URL to be deprecated, that is, immediately feedback an HTTP response code of 410 (deprecated). Using this tag, you can indicate that the page has been deprecated and does not exist.

handler| H=content-handler (enforces the specified content processor)

Changzi the content processor for the target file is Content-handler. For example, the Scriptalias directive used to emulate the Mod_alias module to force all files in the mapped folder to be handled by the "Cgi-script" processor.

Last| L (end rule)

Stops the rewrite operation immediately and no longer applies another rewrite rule. It corresponds to the last command in Perl or the break command in the C language. This flag is used to prevent URLs that are currently overridden from being rewritten again by subsequent rules. For example, you can use it to override the URL of the root path (/) to a URL that actually exists (for example:/e/www/).

Next| N (from scratch)

Re-executes the rewrite operation (starting with the first rule). The URL that was processed again at this point is not the original URL, but the URL that was processed by the last rewrite rule. It corresponds to the next command in Perl or the Continue command in the C language. This tag can restart the rewrite operation (immediately to the beginning of the loop). But be careful not to create a dead loop!

nocase| NC (ignoring case)

It makes the pattern ignore case, that is, there is no difference between A-Z and a-Z when pattern matches the current URL.

Noescape|ne (The URI is not escaped in the output)

This flag prevents Mod_rewrite from applying a general URI escape rule to the overridden result. In general, special characters (%, $,; etc.) are escaped to the equivalent hexadecimal encoding (%25′,%24′,%3b, etc.). This flag prevents such escapes from allowing symbols such as percent signs to appear in the output, such as:

rewriterule/foo/(. *)/bar?arg=p1\%3d$1 [R,ne] enables/foo/zed to move to a secure request/bar?arg=p1=zed

nosubreq| NS (Do not process internal sub-requests)

This token forces the rewrite engine to skip the rewrite rule when the current request is an internal child request. For example, when Mod_include tries to search the directory default file (INDEX.XXX), Apache generates a child request internally. For a child request, the rewrite rule is not necessarily useful, and it may even throw an error if the entire rule set works. Therefore, you can use this tag to exclude certain rules. Usage guidelines: If you add a CGI script prefix to a URL to force them to be handled by a CGI script, the error rate (or resource overhead) of the child request processing is high, in which case the token can be used.

proxy| P (mandatory for proxy)

This token causes the replacement component to be internally forced to send as a proxy request, and immediately interrupts the rewrite process and then transfers the processing to the Mod_proxy module. You must make sure that this replacement string is a valid URI that can be processed by mod_proxy (for example, starting with http://www.phpernote.com), or you will get an error returned by a proxy module. With this tag, some remote components can be mapped to the local server domain name space, thereby enhancing the functionality of the Proxypass directive. Note: To use this feature, the Mod_proxy module must already be enabled.

Passthrough|pt (hand over to the next processor)

This flag forces the rewrite engine to set the URI field in the internal REQUEST_REC structure to the value of the FileName field, a small modification that allows the output of the rewriterule instruction to be Alias, Scriptalias, from the URI to the file name, Redirect and other instructions for follow-up processing [original: This flag was just a hack to enable post-processing of the output of rewriterule directives, using Ali As, Scriptalias, Redirect, and other directives from various uri-to-filename translators.

Give an example of what it means: if you want to rewrite/abc to/def, and then use Mod_alias to convert/def to/ghi, you can:

Rewriterule ^/abc (. *)/def$1 [PT]
Alias/def/ghi

If the PT mark is omitted, though the uri=/abc/... Rewrite for filename=/def/... Section works fine, but subsequent mod_alias are invalidated when attempting to convert a URI to a file name. Note: You must use this tag if you need to mix multiple modules that convert URIs to file names: Mixed use of Mod_alias and mod_rewrite here is a typical example.

qsappend| QSA (append query string)

This flag forces the rewrite engine to append a query string to an existing replacement string, rather than a simple replacement. You can use this tag if you need to add information to the request string through a rewrite rule.

Redirect| R [=code] (forced redirection)

If substitution begins with http://thishost[:thisport]/(making the new URL a URI), an external redirect can be enforced. If code is not specified, an HTTP response code of 302 (temporary move) is generated. If you need to use a different response code in the range of 300-400, just specify it here (or use one of the following symbol names: Temp (default), Permanent, seeother). You can use it to feed the normalized URL back to the client, such as "/~" to "/u/", or always to/u/user with a slash, and so on.

Note: When you use this tag, you must make sure that the replacement field is a valid URL. Otherwise, it will point to an invalid location! And keep in mind that this tag itself simply adds a http://thishost[:thisport]/prefix to the URL, and the rewrite operation continues. In general, you will also want to stop the rewrite operation and immediately redirect, then you need to use the L flag.

skip| S=num (Skip the successor rule)

This flag forces the rewrite engine to skip NUM rules after the current matching rule. It simulates the IF-THEN-ELSE structure: The last rule is the then clause, and the skip=n rule that is skipped is the ELSE clause. Note: it and chain| The C tag is different!

type| T=mime-type (Force MIME type)

The force target file has a MIME type of mime-type and can be used to force the content type to be set based on certain conditions. For example, the following instruction allows a. php file to be displayed by mod_php according to the MIME type of the PHP source code (APPLICATION/X-HTTPD-PHP-SOURCE) in the case of a. Phps extension:

Rewriterule ^ (. +\.php) S $ $ [T=application/x-httpd-php-source]

Articles you may be interested in

    • PhpMyAdmin cannot start session without errors error resolution
    • Htaccess how to set up a picture of a directory in an anti-theft chain
    • PHP $this, Static, final, const, self, and several other key words to use
    • Using the. htaccess Block List Directory
    • Fatal error Class ' soapclient ' not found in ... Error handling methods
    • PHP Tip maximum execution time of seconds exceeded ... The wrong solution
    • 10 sections of practical. htaccess Code Snippets
    • Use. htaccess to deny an IP access to a Web site

http://www.bkjia.com/PHPjc/764191.html www.bkjia.com true http://www.bkjia.com/PHPjc/764191.html techarticle have contacted the. htaccess file friends whether the opposite of some of the syntax is not very understanding, often see a rule followed by some uppercase L NC R QSA What, know what they mean ...

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