Reprint. htaccess file Rewriterule Syntax rules

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

See: http://blog.csdn.net/scchary/article/details/40045807

   #--represents a comment at the beginning of the line.      [F]--forbidden (Forbidden): Command Server returns 403 Forbidden error to user browser      [l]--last Rule (last rule): tells the server to stop rewriting URLs 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 through the Mod_proxy module      [C]--chain (bundle): tells the server to bundle the current rules with the previous rules     " Redirect| R [=code] "(forced 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 300-400 range, just specify it here (orUse 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" 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 (release): Let Mod_ The rewrite module passes the rewritten URL back to Apache for further processing      [Or]--or (Logical OR): Connect the two expressions with logic or, if the result is true, apply the subsequent related rules      [ne]--no Escape (Disable Escape): The command server disables the escape character flag on output to prevent mod_rewrite from applying a general URI escape rule to the overridden result. 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 sub-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 parameter of the Get .      [S=x]--skip (Skip): If a specified condition is met, skip the next 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 type): 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 called:    rewriterule ^ ( . +\.php) S $ [t=application/x-httpd-php-source]     []--matches a character set, such as [XYZ] can match x, y, or z      []+--For example [xyz]+] in any order, the number of times matches the appearance of X, Y, z      [^]--character ^ represents a complement to the character set. [^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 letter a appears n times and matches when the condition is met. For example x{3} only matches with XXX      a{n,}--specified letter a appearsThe number of times is at least n times, for example X{3,} can be matched with XXX or xxxx      a{n,m}--specifies that a appears at least N to M times.      ()--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), the 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? Will match the "empty character" or a x    ! --Logical non. For example, "!string" will match all strings except "string"     . --denotes arbitrary string     –--command Apache "do not" rewrite URLs, such as "Xxx.domain.com.*–[f"      +-- Matches at least one arbitrary character, for example g+ matches a string that starts with G and has at least one character followed by      *--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.      \. --Escaped as dot character (dot regular expression can match any character)     /*--0 or more forward slashes     . *--0 or more arbitrary characters (that is, matches anymeaning string, including null characters)      ^$--match "null character", "Blank line"      ^.*$--match any string (one line only)       [^/.]--matches any character that is not a ' forward slash ' or ' point '      [^/.] +--matches the first character neither "forward slash" nor "point", subsequent characters can be "forward slash" or "dot" string      http://--Match "http//"       ^domain.*--matches a string starting with "domain"      ^domain\.com$--matches only "domain.com"      -d--  test whether the string is an existing directory     -f--test string is a file that already exists     -s-- Test if the string refers to a file that 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.