code
ref
Cheat Sheets
Quick Reference
JSON Formatter
Learn
Tools
Browser Support
Search…
Ctrl K
Cheat Sheets
/
Systems
/
mod_rewrite
mod_rewrite
Apache mod_rewrite directives, RewriteRule flags, server variables and condition tests.
Official reference ↗
Directives
RewriteEngine
RewriteRule
RewriteCond
RewriteBase
RewriteMap
RewriteOptions
RewriteRule Flags
[L] last
[END] end
[R=301] redirect
[NC] nocase
[QSA] qsappend
[QSD] qsdiscard
[NE] noescape
[PT] passthrough
[P] proxy
[F] forbidden
[G] gone
[C] chain
[S=n] skip
[N] next
[E=var:val] env
[CO] cookie
[T=type] type
[H=handler]
[B] escape backrefs
[DPI] discardpath
[NS] nosubreq
RewriteCond
Flags
[NC] nocase
[OR] ornext
[NV] novary
Tests
-d directory
-f file
-s non-empty
-l symlink
-F via subrequest
-U URL via subrequest
=string
<string
>string
-eq -ne -lt -gt
!pattern
expr
Server Variables
HTTP Headers
HTTP_HOST
HTTP_USER_AGENT
HTTP_REFERER
HTTP_COOKIE
HTTP_ACCEPT
HTTP_FORWARDED
Request
REQUEST_URI
REQUEST_FILENAME
REQUEST_METHOD
REQUEST_SCHEME
QUERY_STRING
THE_REQUEST
REMOTE_ADDR
REMOTE_HOST
HTTPS
Server & Time
SERVER_NAME
SERVER_PORT
DOCUMENT_ROOT
SERVER_PROTOCOL
TIME
TIME_YEAR
TIME_HOUR
ENV:name
SSL:name
Patterns & Backreferences
Regex
^
$
.
[chars]
[^chars]
?
*
+
(...)
a|b
!
Backreferences
$1 … $9
%1 … %9
${map:key}
Related
Redirect
RedirectMatch
Alias
AllowOverride
FallbackResource
<If>
Guides
Introduction
Flags
Redirecting & remapping
Access control
Virtual hosts
Using RewriteMap
Advanced techniques
When not to use it
.htaccess files