Reprint. htaccess file Rewriterule Syntax rules

Source: Internet
Author: User
Tags php source code response code 403 forbidden error

 # #-Represents a comment at the beginning of a line. [F]--forbidden (Forbidden): The command server returns 403 Forbidden error to the user's browser [l]--last rule (last rule): tells the server to stop rewriting the URL after this rule has finished executing. 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/"). [N]--next (Next rule): tells the server to continue rewriting, directing all rewrite instructions to execute. 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! [G]--gone (missing): Command server returns 410 Gone (no longer exists) error message [P]--proxy (proxy): tells the server to process user requests via Mod_proxy module [C]--chain (bundle)] : tells the server to bundle the current rule with the previous rule "redirect| R [=code] "(Force redirect) [R]--redirect (redirect): The command server issues a redirect message so that the user's browser issues a request for a rewritten/modified (rewrite/modify) URL. 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 remember, this tag itself is just a URL plus an http://thishost[:thisport]/prefix, the rewrite operation will still continue.     In general, you will also want to stop the rewrite operation and immediately redirect, then you need to use the "L" tag. [nc]--no case: The URL requested by the client is not case-sensitive.     It makes the pattern ignore case, that is, when pattern matches the current URL, "A-Z" and "A-Z" have no difference [pt]--pass Through: Let the Mod_rewrite module pass the rewritten URL back to Apache for further processing [Or]--or (Logical OR): Connect two expressions with logic or, if the result is true, apply subsequent related rules [Ne]--no Escape (Disable Escape): The command server disables the escape character flag on output to block mod_rewrite to the overridden result should Rules are escaped with a regular URI. In general, special characters ("%", "$", ";") And so on) are escaped to the equivalent hexadecimal encoding ("%25′,"%24′, "%3b", etc.). This flag prevents such escapes from allowing symbols such as percent sign to appear in the output, such as: rewriterule/foo/(. *)/bar?arg=p1\%3d$1 [R,ne] allows "/foo/zed to turn to a secure request"/bar?arg=p1=     Zed ". [Ns]--no subrequest (Disable child request): Skips the current command if there is an internal child request. 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.     [Qsa]--append query string]: The command server appends the query string at the end of the URL to maintain the URL parameters of the get. [S=x]--skip (skipped): If a specified condition is met, skip the subsequent X-rule [E=variable:value]--environmental VariaBLE (environment variable): The command server assigns the value values to the variable variable [t=mime-type]--mime type (MIME types): Declares the MIME type to which the target resource belongs. 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 instructions can let. PHP files are displayed by mod_php according to the MIME type of PHP source code (APPLICATION/X-HTTPD-PHP-SOURCE) in the case of a. Phps extension: rewriterule ^ (. +\.php) S $ $ [t= Application/x-httpd-php-source] []--matches a character set, for example [XYZ] can match x, y, or Z []+--for example [xyz]+ will be in any order, number of times match x, y, z occurrences [^]--character ^ represents a complement to a set of characters. [^XYZ] matches a string that does not have X, y, or Z [a-z]--hyphen (-) to match all strings from letter A to letter Z a{n}--specifies that the number of occurrences of the letter A is n times, which matches when the condition is met.     For example, x{3} matches only xxx a{n,}--Specifies that the letter a appears at least n times, such as x{3, which can be matched to XXX or xxxx a{n,m}--specify a number of occurrences of at least N to M. ()--used to group regular expressions, strings that satisfy the first set of regular expressions are stored in the variable, and so on. If the parentheses are not regular expressions, for example (perishable)? Press will be able to match the press ^--with or without the perishable prefix at the beginning of the line.     Note: The meaning of [^] in brackets is different. $--at the end of the line? --such as Monzas? Will match Monza or Monzas, and Mon (za)? Will match Mon or Monza. Another example of x? Matches the "null character" or an X! --Logical non. For example, "!string" will match all strings except "string". --denotes arbitrary string –--command Apache "do not" rewrite the URL, for example "xxx.domain.com.*–[f]" +--matches at least one arbitrary character, for example g+ matches with a G beginning, and at least one character after theString *--matches 0 or more characters, such as ". *" to match any string | --Logical "or", unlike [or], it only matches strings, for example (X|y) matches x or y \--escape characters. You can escape the opening parenthesis (the sharp character ^ dollar sign $ exclamation point!). asterisk * Pipe symbol | closing parenthesis) etc. --Escape is a dot character (a dot regular the expression can match any character)/*--0 or more forward slashes. *--0 or more arbitrary characters (that is, matches any string, including null characters) ^$--matches "empty character", "Empty line" ^.*$--horse Match any string (one line only) [^/.]--matches any character that is neither a forward slash nor a point [^/.] +--matches the first character neither "forward slash" nor "point", the successor character can be a "forward slash" or "dot" string http://--match "http//" ^domain.*--matches a string starting with "domain" ^domain\ . com$--matches only "domain.com"-d--test if the string is an existing directory-f--test string is an existing file-s--test string refers to whether the file has a "not 0" value

  

Reprint. htaccess file Rewriterule Syntax rules

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.