mod_rewrite
RewriteRule Flags
RewriteRule Flags
- C
- Chained with next rule
- CO=cookie
- Set specified cookie
- E=var:-value
- Set environmental variable “var” to “value”
- F
- Forbidden (403 header)
- G
- Gone no longer exists
- H=handler
- Set handler
- L
- Last stop processing rules
- N
- Next continue processing
- NC
- Case insensitive
- NE
- Do not escape output
- NS
- Ignore if subrequest
- P
- Proxy
- PT
- Pass through
- QSA
- Append query string
- R[=code]
- Redirect to new URL, with optional code (see below)
- S=x
- Skip next x rules
- T=mime-type
- Set mime type
RegExp
Regular Expressions Syntax
- ^
- Start of string
- .
- Any single character
- (...)
- Group section
- (a|b)
- a or b
- [^abc]
- Not in range
- [:blank:]
- Space or tab
- [:punct:]
- Any punctu-ation symbol
- [:space:]
- Any space character
- [abc]
- In range (a, b or c)
- \
- Escape character
- \s
- White space
- $
- End of string
- a?
- Zero or one of a
- a{,6}
- Up to 6 of a
- a{3,}
- 3 or more of a
- a{3,6}
- 3 to 6 of a
- a{3,6}?
- 3 to 6 of a, ungreedy
- a{3}
- Exactly 3 of a
- a*
- Zero or more of a
- a*?
- Zero or more, ungreedy
- a+
- One or more of a
- a+?
- One or more, ungreedy
Miscellaneous
RewriteCond Flags
- # Nice URLs (no query string)
-
- OR
- Combine with next rule using 'OR' instead of the default of 'AND'
Redirection Header Codes
- 301
- Moved permanently
- 302
- Moved temporarily (default)
Sample Rule: Temporary Page Move