Blame docs/manual/mod/mod_rewrite.html.en

Packit 90a5c9
Packit 90a5c9
Packit 90a5c9
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
Packit 90a5c9
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
Packit 90a5c9
Packit 90a5c9
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Packit 90a5c9
              This file is generated from xml source: DO NOT EDIT
Packit 90a5c9
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Packit 90a5c9
      -->
Packit 90a5c9
<title>mod_rewrite - Apache HTTP Server Version 2.4</title>
Packit 90a5c9
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
Packit 90a5c9
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
Packit 90a5c9
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
Packit 90a5c9
<script src="../style/scripts/prettify.min.js" type="text/javascript">
Packit 90a5c9
</script>
Packit 90a5c9
Packit 90a5c9
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
Packit 90a5c9
<body>
Packit 90a5c9
Packit 90a5c9

Modules | Directives | FAQ | Glossary | Sitemap

Packit 90a5c9

Apache HTTP Server Version 2.4

Packit 90a5c9
Packit 90a5c9
<-
Packit 90a5c9
Packit 90a5c9
Apache > HTTP Server > Documentation > Version 2.4 > Modules
Packit 90a5c9
Packit 90a5c9

Apache Module mod_rewrite

Packit 90a5c9
Packit 90a5c9

Available Languages:  en  |

Packit 90a5c9
 fr 

Packit 90a5c9
Packit 90a5c9
Description:Provides a rule-based rewriting engine to rewrite requested
Packit 90a5c9
URLs on the fly
Packit 90a5c9
Status:Extension
Packit 90a5c9
Module Identifier:rewrite_module
Packit 90a5c9
Source File:mod_rewrite.c
Packit 90a5c9

Summary

Packit 90a5c9
Packit 90a5c9
	

The mod_rewrite module uses a rule-based rewriting

Packit 90a5c9
      engine, based on a PCRE regular-expression parser, to rewrite requested URLs on
Packit 90a5c9
      the fly. By default, mod_rewrite maps a URL to a filesystem
Packit 90a5c9
      path. However, it can also be used to redirect one URL to another URL, or
Packit 90a5c9
      to invoke an internal proxy fetch.

Packit 90a5c9
      

mod_rewrite provides a flexible and powerful way to

Packit 90a5c9
      manipulate URLs using an unlimited number of rules. Each rule can have an
Packit 90a5c9
      unlimited number of attached rule conditions, to allow you to rewrite URL
Packit 90a5c9
      based on server variables, environment variables, HTTP headers, or time
Packit 90a5c9
      stamps.

Packit 90a5c9
      

mod_rewrite operates on the full URL path, including the

Packit 90a5c9
      path-info section. A rewrite rule can be invoked in
Packit 90a5c9
      httpd.conf or in .htaccess. The path generated
Packit 90a5c9
      by a rewrite rule can include a query string, or can lead to internal
Packit 90a5c9
      sub-processing, external request redirection, or internal proxy
Packit 90a5c9
      throughput.

Packit 90a5c9
Packit 90a5c9
      

Further details, discussion, and examples, are provided in the

Packit 90a5c9
      detailed mod_rewrite documentation.

Packit 90a5c9
Packit 90a5c9
Support Apache!

Topics

Packit 90a5c9
    Packit 90a5c9
  • Logging
  • Packit 90a5c9

    Directives

    Packit 90a5c9
      Packit 90a5c9
    • RewriteBase
    • Packit 90a5c9
    • RewriteCond
    • Packit 90a5c9
    • RewriteEngine
    • Packit 90a5c9
    • RewriteMap
    • Packit 90a5c9
    • RewriteOptions
    • Packit 90a5c9
    • RewriteRule
    • Packit 90a5c9
      Packit 90a5c9

      Bugfix checklist

      See also

      Packit 90a5c9
        Packit 90a5c9
      • Comments
      • Packit 90a5c9
        top
        Packit 90a5c9
        Packit 90a5c9

        Logging

        Packit 90a5c9
        Packit 90a5c9
            

        mod_rewrite offers detailed logging of its actions

        Packit 90a5c9
            at the trace1 to trace8 log levels. The
        Packit 90a5c9
            log level can be set specifically for mod_rewrite
        Packit 90a5c9
            using the LogLevel directive: Up to
        Packit 90a5c9
            level debug, no actions are logged, while trace8
        Packit 90a5c9
            means that practically all actions are logged.

        Packit 90a5c9
        Packit 90a5c9
            
        Packit 90a5c9
              Using a high trace log level for mod_rewrite
        Packit 90a5c9
              will slow down your Apache HTTP Server dramatically! Use a log
        Packit 90a5c9
              level higher than trace2 only for debugging!
        Packit 90a5c9
            
        Packit 90a5c9
        Packit 90a5c9
            

        Example

        LogLevel alert rewrite:trace3
        Packit 90a5c9
        Packit 90a5c9
        Packit 90a5c9
            

        RewriteLog

        Packit 90a5c9
              

        Those familiar with earlier versions of

        Packit 90a5c9
              mod_rewrite will no doubt be looking for the
        Packit 90a5c9
              RewriteLog and RewriteLogLevel
        Packit 90a5c9
              directives. This functionality has been completely replaced by the
        Packit 90a5c9
              new per-module logging configuration mentioned above.
        Packit 90a5c9
              

        Packit 90a5c9
        Packit 90a5c9
              

        To get just the mod_rewrite-specific log

        Packit 90a5c9
              messages, pipe the log file through grep:

        Packit 90a5c9
            

        Packit 90a5c9
            tail -f error_log|fgrep '[rewrite:'
        Packit 90a5c9
            

        Packit 90a5c9
            
        Packit 90a5c9
        Packit 90a5c9
        Packit 90a5c9
        top
        Packit 90a5c9
        Packit 90a5c9
        Packit 90a5c9
        Description:Sets the base URL for per-directory rewrites
        Packit 90a5c9
        Syntax:RewriteBase URL-path
        Packit 90a5c9
        Default:None
        Packit 90a5c9
        Context:directory, .htaccess
        Packit 90a5c9
        Override:FileInfo
        Packit 90a5c9
        Status:Extension
        Packit 90a5c9
        Module:mod_rewrite
        Packit 90a5c9
        Packit 90a5c9
              

        The RewriteBase directive specifies the

        Packit 90a5c9
              URL prefix to be used for per-directory (htaccess)
        Packit 90a5c9
              RewriteRule directives that
        Packit 90a5c9
              substitute a relative path.

        Packit 90a5c9
              

        This directive is required when you use a relative path

        Packit 90a5c9
              in a substitution in per-directory (htaccess) context unless any 
        Packit 90a5c9
              of the following conditions are true:

        Packit 90a5c9
              
          Packit 90a5c9
                    
        • The original request, and the substitution, are underneath the
        • Packit 90a5c9
                         DocumentRoot
          Packit 90a5c9
                         (as opposed to reachable by other means, such as
          Packit 90a5c9
                         Alias).
          Packit 90a5c9
                    
        • The filesystem path to the directory containing the
        • Packit 90a5c9
                         RewriteRule,
          Packit 90a5c9
                         suffixed by the relative
          Packit 90a5c9
                         substitution is also valid as a URL path on the server
          Packit 90a5c9
                         (this is rare).
          Packit 90a5c9
                    
        • In Apache HTTP Server 2.4.16 and later, this directive may be
        • Packit 90a5c9
                          omitted when the request is mapped via
          Packit 90a5c9
                          Alias
          Packit 90a5c9
                          or mod_userdir.
          Packit 90a5c9
                
          Packit 90a5c9
          Packit 90a5c9

          In the example below, RewriteBase is necessary

          Packit 90a5c9
              to avoid rewriting to http://example.com/opt/myapp-1.2.3/welcome.html
          Packit 90a5c9
              since the resource was not relative to the document root.  This
          Packit 90a5c9
              misconfiguration would normally cause the server to look for an "opt"
          Packit 90a5c9
              directory under the document root.

          Packit 90a5c9
          DocumentRoot "/var/www/example.com"
          Packit 90a5c9
          AliasMatch "^/myapp" "/opt/myapp-1.2.3"
          Packit 90a5c9
          <Directory "/opt/myapp-1.2.3">
          Packit 90a5c9
              RewriteEngine On
          Packit 90a5c9
              RewriteBase "/myapp/"
          Packit 90a5c9
              RewriteRule "^index\.html$"  "welcome.html"
          Packit 90a5c9
          </Directory>
          Packit 90a5c9
          Packit 90a5c9
          Packit 90a5c9
          Packit 90a5c9
          Packit 90a5c9
          top
          Packit 90a5c9
          Packit 90a5c9
          Packit 90a5c9
          Description:Defines a condition under which rewriting will take place
          Packit 90a5c9
          Packit 90a5c9
          Syntax: RewriteCond
          Packit 90a5c9
                TestString CondPattern [flags]
          Packit 90a5c9
          Context:server config, virtual host, directory, .htaccess
          Packit 90a5c9
          Override:FileInfo
          Packit 90a5c9
          Status:Extension
          Packit 90a5c9
          Module:mod_rewrite
          Packit 90a5c9
          Packit 90a5c9
                

          The RewriteCond directive defines a

          Packit 90a5c9
                rule condition. One or more RewriteCond
          Packit 90a5c9
                can precede a RewriteRule
          Packit 90a5c9
                directive. The following rule is then only used if both
          Packit 90a5c9
                the current state of the URI matches its pattern, and if these conditions are met.

          Packit 90a5c9
          Packit 90a5c9
                

          TestString is a string which can contain the

          Packit 90a5c9
                following expanded constructs in addition to plain text:

          Packit 90a5c9
          Packit 90a5c9
                
            Packit 90a5c9
                    
          • Packit 90a5c9
                      RewriteRule backreferences: These are
            Packit 90a5c9
                      backreferences of the form $N
            Packit 90a5c9
                      (0 <= N <= 9). $1 to $9 provide access to the grouped
            Packit 90a5c9
                      parts (in parentheses) of the pattern, from the
            Packit 90a5c9
                      RewriteRule which is subject to the current
            Packit 90a5c9
                      set of RewriteCond conditions. $0 provides
            Packit 90a5c9
                      access to the whole string matched by that pattern.
            Packit 90a5c9
                    
            Packit 90a5c9
                    
          • Packit 90a5c9
                      RewriteCond backreferences: These are
            Packit 90a5c9
                      backreferences of the form %N
            Packit 90a5c9
                      (0 <= N <= 9). %1 to %9 provide access to the grouped
            Packit 90a5c9
                      parts (again, in parentheses) of the pattern, from the last matched
            Packit 90a5c9
                      RewriteCond in the current set
            Packit 90a5c9
                      of conditions. %0 provides access to the whole string matched by
            Packit 90a5c9
                      that pattern.
            Packit 90a5c9
                    
            Packit 90a5c9
                    
          • Packit 90a5c9
                      RewriteMap expansions: These are
            Packit 90a5c9
                      expansions of the form ${mapname:key|default}.
            Packit 90a5c9
                      See the documentation for
            Packit 90a5c9
                      RewriteMap for more details.
            Packit 90a5c9
                    
            Packit 90a5c9
                    
          • Packit 90a5c9
                      Server-Variables: These are variables of
            Packit 90a5c9
                      the form
            Packit 90a5c9
                        %{ NAME_OF_VARIABLE
            Packit 90a5c9
                        }
            Packit 90a5c9
                      where NAME_OF_VARIABLE can be a string taken
            Packit 90a5c9
                      from the following list:
            Packit 90a5c9
            Packit 90a5c9
                      
            Packit 90a5c9
                      
            Packit 90a5c9
                        
            Packit 90a5c9
                          HTTP headers: connection & request: 
            Packit 90a5c9
                        
            Packit 90a5c9
            Packit 90a5c9
                        
            Packit 90a5c9
                          
            Packit 90a5c9
                             HTTP_ACCEPT
            Packit 90a5c9
                             HTTP_COOKIE
            Packit 90a5c9
                             HTTP_FORWARDED
            Packit 90a5c9
                             HTTP_HOST
            Packit 90a5c9
                             HTTP_PROXY_CONNECTION
            Packit 90a5c9
                             HTTP_REFERER
            Packit 90a5c9
                             HTTP_USER_AGENT
            Packit 90a5c9
                          
            Packit 90a5c9
            Packit 90a5c9
                          
            Packit 90a5c9
                             AUTH_TYPE
            Packit 90a5c9
                             CONN_REMOTE_ADDR
            Packit 90a5c9
                             CONTEXT_PREFIX
            Packit 90a5c9
                             CONTEXT_DOCUMENT_ROOT
            Packit 90a5c9
                             IPV6
            Packit 90a5c9
                             PATH_INFO
            Packit 90a5c9
                             QUERY_STRING
            Packit 90a5c9
                             REMOTE_ADDR
            Packit 90a5c9
                             REMOTE_HOST
            Packit 90a5c9
                             REMOTE_IDENT
            Packit 90a5c9
                             REMOTE_PORT
            Packit 90a5c9
                             REMOTE_USER
            Packit 90a5c9
                             REQUEST_METHOD
            Packit 90a5c9
                             SCRIPT_FILENAME
            Packit 90a5c9
                          
            Packit 90a5c9
            Packit 90a5c9
                          
            Packit 90a5c9
                        
            Packit 90a5c9
            Packit 90a5c9
                        
            Packit 90a5c9
                          server internals: date and time: specials:
            Packit 90a5c9
                        
            Packit 90a5c9
            Packit 90a5c9
                        
            Packit 90a5c9
                          
            Packit 90a5c9
                             DOCUMENT_ROOT
            Packit 90a5c9
                             SCRIPT_GROUP
            Packit 90a5c9
                             SCRIPT_USER
            Packit 90a5c9
                             SERVER_ADDR
            Packit 90a5c9
                             SERVER_ADMIN
            Packit 90a5c9
                             SERVER_NAME
            Packit 90a5c9
                             SERVER_PORT
            Packit 90a5c9
                             SERVER_PROTOCOL
            Packit 90a5c9
                             SERVER_SOFTWARE
            Packit 90a5c9
                          
            Packit 90a5c9
            Packit 90a5c9
                          
            Packit 90a5c9
                             TIME_YEAR
            Packit 90a5c9
                             TIME_MON
            Packit 90a5c9
                             TIME_DAY
            Packit 90a5c9
                             TIME_HOUR
            Packit 90a5c9
                             TIME_MIN
            Packit 90a5c9
                             TIME_SEC
            Packit 90a5c9
                             TIME_WDAY
            Packit 90a5c9
                             TIME
            Packit 90a5c9
                          
            Packit 90a5c9
            Packit 90a5c9
                          
            Packit 90a5c9
                             API_VERSION
            Packit 90a5c9
                             CONN_REMOTE_ADDR
            Packit 90a5c9
                             HTTPS
            Packit 90a5c9
                             IS_SUBREQ
            Packit 90a5c9
                             REMOTE_ADDR
            Packit 90a5c9
                             REQUEST_FILENAME
            Packit 90a5c9
                             REQUEST_SCHEME
            Packit 90a5c9
                             REQUEST_URI
            Packit 90a5c9
                             THE_REQUEST
            Packit 90a5c9
                          
            Packit 90a5c9
                        
            Packit 90a5c9
                      
            Packit 90a5c9
            Packit 90a5c9
                            

            These variables all

            Packit 90a5c9
                            correspond to the similarly named HTTP
            Packit 90a5c9
                            MIME-headers, C variables of the Apache HTTP Server or
            Packit 90a5c9
                            struct tm fields of the Unix system.
            Packit 90a5c9
                            Most are documented here
            Packit 90a5c9
                            or elsewhere in the Manual or in the CGI specification.

            Packit 90a5c9
            Packit 90a5c9
                            

            SERVER_NAME and SERVER_PORT depend on the values of

            Packit 90a5c9
                            UseCanonicalName and
            Packit 90a5c9
                            UseCanonicalPhysicalPort
            Packit 90a5c9
                            respectively.

            Packit 90a5c9
            Packit 90a5c9
                            

            Those that are special to mod_rewrite include those below.

            Packit 90a5c9
                            
            Packit 90a5c9
                              
            API_VERSION
            Packit 90a5c9
            Packit 90a5c9
                              
            This is the version of the Apache httpd module API
            Packit 90a5c9
                              (the internal interface between server and
            Packit 90a5c9
                              module) in the current httpd build, as defined in
            Packit 90a5c9
                              include/ap_mmn.h. The module API version
            Packit 90a5c9
                              corresponds to the version of Apache httpd in use (in
            Packit 90a5c9
                              the release version of Apache httpd 1.3.14, for
            Packit 90a5c9
                              instance, it is 19990320:10), but is mainly of
            Packit 90a5c9
                              interest to module authors.
            Packit 90a5c9
            Packit 90a5c9
                              
            CONN_REMOTE_ADDR
            Packit 90a5c9
            Packit 90a5c9
                              
            Since 2.4.8: The peer IP address of the connection (see the
            Packit 90a5c9
                              mod_remoteip module).
            Packit 90a5c9
            Packit 90a5c9
                              
            HTTPS
            Packit 90a5c9
            Packit 90a5c9
                              
            Will contain the text "on" if the connection is
            Packit 90a5c9
                              using SSL/TLS, or "off" otherwise.  (This variable
            Packit 90a5c9
                              can be safely used regardless of whether or not
            Packit 90a5c9
                              mod_ssl is loaded).
            Packit 90a5c9
            Packit 90a5c9
                              
            IS_SUBREQ
            Packit 90a5c9
            Packit 90a5c9
                              
            Will contain the text "true" if the request
            Packit 90a5c9
                              currently being processed is a sub-request,
            Packit 90a5c9
                              "false" otherwise. Sub-requests may be generated
            Packit 90a5c9
                              by modules that need to resolve additional files
            Packit 90a5c9
                              or URIs in order to complete their tasks.
            Packit 90a5c9
            Packit 90a5c9
                              
            REMOTE_ADDR
            Packit 90a5c9
            Packit 90a5c9
                              
            The IP address of the remote host (see the
            Packit 90a5c9
                              mod_remoteip module).
            Packit 90a5c9
            Packit 90a5c9
                              
            REQUEST_FILENAME
            Packit 90a5c9
            Packit 90a5c9
                              
            The full local filesystem path to the file or
            Packit 90a5c9
                              script matching the request, if this has already
            Packit 90a5c9
                              been determined by the server at the time
            Packit 90a5c9
                              REQUEST_FILENAME is referenced. Otherwise,
            Packit 90a5c9
                              such as when used in virtual host context, the same
            Packit 90a5c9
                              value as REQUEST_URI.  Depending on the value of
            Packit 90a5c9
                              AcceptPathInfo, the
            Packit 90a5c9
                              server may have only used some leading components of the
            Packit 90a5c9
                              REQUEST_URI to map the request to a file.
            Packit 90a5c9
                              
            Packit 90a5c9
            Packit 90a5c9
                              
            REQUEST_SCHEME
            Packit 90a5c9
            Packit 90a5c9
                              
            Will contain the scheme of the request (usually
            Packit 90a5c9
                              "http" or "https"). This value can be influenced with
            Packit 90a5c9
                              ServerName.
            Packit 90a5c9
            Packit 90a5c9
                              
            REQUEST_URI
            Packit 90a5c9
            Packit 90a5c9
                              
            The path component of the requested URI,
            Packit 90a5c9
                              such as "/index.html".  This notably excludes the
            Packit 90a5c9
                              query string which is available as its own variable
            Packit 90a5c9
                              named QUERY_STRING.
            Packit 90a5c9
            Packit 90a5c9
                              
            THE_REQUEST
            Packit 90a5c9
            Packit 90a5c9
                              
            The full HTTP request line sent by the
            Packit 90a5c9
                              browser to the server (e.g., "GET
            Packit 90a5c9
                              /index.html HTTP/1.1"). This does not
            Packit 90a5c9
                              include any additional headers sent by the
            Packit 90a5c9
                              browser.  This value has not been unescaped
            Packit 90a5c9
                              (decoded), unlike most other variables below.
            Packit 90a5c9
            Packit 90a5c9
                            
            Packit 90a5c9
                    
            Packit 90a5c9
                  
            Packit 90a5c9
            Packit 90a5c9
                  

            If the TestString has the special value expr,

            Packit 90a5c9
                  the CondPattern will be treated as an
            Packit 90a5c9
                  ap_expr. HTTP headers referenced in the
            Packit 90a5c9
                  expression will be added to the Vary header if the novary
            Packit 90a5c9
                  flag is not given.

            Packit 90a5c9
            Packit 90a5c9
                  

            Other things you should be aware of:

            Packit 90a5c9
            Packit 90a5c9
                  
              Packit 90a5c9
                      
            1. Packit 90a5c9
                      

              The variables SCRIPT_FILENAME and REQUEST_FILENAME

              Packit 90a5c9
                      contain the same value - the value of the
              Packit 90a5c9
                      filename field of the internal
              Packit 90a5c9
                      request_rec structure of the Apache HTTP Server.
              Packit 90a5c9
                      The first name is the commonly known CGI variable name
              Packit 90a5c9
                      while the second is the appropriate counterpart of
              Packit 90a5c9
                      REQUEST_URI (which contains the value of the
              Packit 90a5c9
                      uri field of request_rec).

              Packit 90a5c9
                      

              If a substitution occurred and the rewriting continues,

              Packit 90a5c9
                      the value of both variables will be updated accordingly.

              Packit 90a5c9
                      

              If used in per-server context (i.e., before the

              Packit 90a5c9
                      request is mapped to the filesystem) SCRIPT_FILENAME and
              Packit 90a5c9
                      REQUEST_FILENAME cannot contain the full local filesystem
              Packit 90a5c9
                      path since the path is unknown at this stage of processing.
              Packit 90a5c9
                      Both variables will initially contain the value of REQUEST_URI
              Packit 90a5c9
                      in that case. In order to obtain the full local filesystem
              Packit 90a5c9
                      path of the request in per-server context, use an URL-based
              Packit 90a5c9
                      look-ahead %{LA-U:REQUEST_FILENAME} to determine
              Packit 90a5c9
                      the final value of REQUEST_FILENAME.

              Packit 90a5c9
              Packit 90a5c9
                      
            2. Packit 90a5c9
                      %{ENV:variable}, where variable can be
              Packit 90a5c9
                      any environment variable, is also available.
              Packit 90a5c9
                      This is looked-up via internal
              Packit 90a5c9
                      Apache httpd structures and (if not found there) via
              Packit 90a5c9
                      getenv() from the Apache httpd server process.
              Packit 90a5c9
              Packit 90a5c9
                      
            3. Packit 90a5c9
                      %{SSL:variable}, where variable is the
              Packit 90a5c9
                      name of an SSL environment
              Packit 90a5c9
                      variable, can be used whether or not
              Packit 90a5c9
                      mod_ssl is loaded, but will always expand to
              Packit 90a5c9
                      the empty string if it is not.  Example:
              Packit 90a5c9
                      %{SSL:SSL_CIPHER_USEKEYSIZE} may expand to
              Packit 90a5c9
                      128. These variables are available even without
              Packit 90a5c9
                      setting the StdEnvVars option of the
              Packit 90a5c9
                      SSLOptions directive.
              Packit 90a5c9
              Packit 90a5c9
                      
            4. Packit 90a5c9
                      %{HTTP:header}, where header can be
              Packit 90a5c9
                      any HTTP MIME-header name, can always be used to obtain the
              Packit 90a5c9
                      value of a header sent in the HTTP request.
              Packit 90a5c9
                      Example: %{HTTP:Proxy-Connection} is
              Packit 90a5c9
                      the value of the HTTP header
              Packit 90a5c9
                      ``Proxy-Connection:''.
              Packit 90a5c9
                      

              If a HTTP header is used in a condition this header is added to

              Packit 90a5c9
                      the Vary header of the response in case the condition evaluates
              Packit 90a5c9
                      to true for the request. It is not added if the
              Packit 90a5c9
                      condition evaluates to false for the request. Adding the HTTP header
              Packit 90a5c9
                      to the Vary header of the response is needed for proper caching.

              Packit 90a5c9
                      

              It has to be kept in mind that conditions follow a short circuit

              Packit 90a5c9
                      logic in the case of the 'ornext|OR' flag
              Packit 90a5c9
                      so that certain conditions might not be evaluated at all.

              Packit 90a5c9
              Packit 90a5c9
                      
            5. Packit 90a5c9
                      %{LA-U:variable}
              Packit 90a5c9
                      can be used for look-aheads which perform
              Packit 90a5c9
                      an internal (URL-based) sub-request to determine the final
              Packit 90a5c9
                      value of variable. This can be used to access
              Packit 90a5c9
                      variable for rewriting which is not available at the current
              Packit 90a5c9
                      stage, but will be set in a later phase.
              Packit 90a5c9
                      

              For instance, to rewrite according to the

              Packit 90a5c9
                      REMOTE_USER variable from within the
              Packit 90a5c9
                      per-server context (httpd.conf file) you must
              Packit 90a5c9
                      use %{LA-U:REMOTE_USER} - this
              Packit 90a5c9
                      variable is set by the authorization phases, which come
              Packit 90a5c9
                      after the URL translation phase (during which
              Packit 90a5c9
                      mod_rewrite operates).

              Packit 90a5c9
                      

              On the other hand, because mod_rewrite implements

              Packit 90a5c9
                      its per-directory context (.htaccess file) via
              Packit 90a5c9
                      the Fixup phase of the API and because the authorization
              Packit 90a5c9
                      phases come before this phase, you just can use
              Packit 90a5c9
                      %{REMOTE_USER} in that context.

              Packit 90a5c9
              Packit 90a5c9
                      
            6. Packit 90a5c9
                      %{LA-F:variable} can be used to perform an internal
              Packit 90a5c9
                      (filename-based) sub-request, to determine the final value
              Packit 90a5c9
                      of variable. Most of the time, this is the same as
              Packit 90a5c9
                      LA-U above.
              Packit 90a5c9
                    
              Packit 90a5c9
              Packit 90a5c9
                    

              CondPattern is the condition pattern,

              Packit 90a5c9
                     a regular expression which is applied to the
              Packit 90a5c9
                    current instance of the TestString.
              Packit 90a5c9
                    TestString is first evaluated, before being matched against
              Packit 90a5c9
                    CondPattern.

              Packit 90a5c9
              Packit 90a5c9
                    

              CondPattern is usually a

              Packit 90a5c9
                    perl compatible regular expression, but there is
              Packit 90a5c9
                    additional syntax available to perform other useful tests against
              Packit 90a5c9
                    the Teststring:

              Packit 90a5c9
              Packit 90a5c9
                    
                Packit 90a5c9
                        
              1. You can prefix the pattern string with a
              2. Packit 90a5c9
                        '!' character (exclamation mark) to negate the result
                Packit 90a5c9
                        of the condition, no matter what kind of CondPattern is used.
                Packit 90a5c9
                        
                Packit 90a5c9
                Packit 90a5c9
                        
              3. Packit 90a5c9
                          You can perform lexicographical string comparisons:
                Packit 90a5c9
                Packit 90a5c9
                          
                Packit 90a5c9
                            
                <CondPattern
                Packit 90a5c9
                            
                Lexicographically precedes
                Packit 90a5c9
                            Treats the CondPattern as a plain string and
                Packit 90a5c9
                            compares it lexicographically to TestString. True if
                Packit 90a5c9
                            TestString lexicographically precedes
                Packit 90a5c9
                            CondPattern.
                Packit 90a5c9
                Packit 90a5c9
                            
                >CondPattern
                Packit 90a5c9
                            
                Lexicographically follows
                Packit 90a5c9
                            Treats the CondPattern as a plain string and
                Packit 90a5c9
                            compares it lexicographically to TestString. True if
                Packit 90a5c9
                            TestString lexicographically follows
                Packit 90a5c9
                            CondPattern.
                Packit 90a5c9
                Packit 90a5c9
                            
                =CondPattern
                Packit 90a5c9
                            
                Lexicographically equal
                Packit 90a5c9
                            Treats the CondPattern as a plain string and
                Packit 90a5c9
                            compares it lexicographically to TestString. True if
                Packit 90a5c9
                            TestString is lexicographically equal to
                Packit 90a5c9
                            CondPattern (the two strings are exactly
                Packit 90a5c9
                            equal, character for character). If CondPattern
                Packit 90a5c9
                            is "" (two quotation marks) this
                Packit 90a5c9
                            compares TestString to the empty string.
                Packit 90a5c9
                Packit 90a5c9
                            
                <=CondPattern
                Packit 90a5c9
                            
                Lexicographically less than or equal to
                Packit 90a5c9
                            Treats the CondPattern as a plain string and
                Packit 90a5c9
                            compares it lexicographically to TestString. True
                Packit 90a5c9
                            if TestString lexicographically precedes
                Packit 90a5c9
                            CondPattern, or is equal to CondPattern
                Packit 90a5c9
                            (the two strings are equal, character for character).
                Packit 90a5c9
                Packit 90a5c9
                            
                >=CondPattern
                Packit 90a5c9
                            
                Lexicographically greater than or equal to
                Packit 90a5c9
                            Treats the CondPattern as a plain string and
                Packit 90a5c9
                            compares it lexicographically to TestString. True
                Packit 90a5c9
                            if TestString lexicographically follows
                Packit 90a5c9
                            CondPattern, or is equal to CondPattern
                Packit 90a5c9
                            (the two strings are equal, character for character).
                Packit 90a5c9
                        
                Packit 90a5c9
                        
                Packit 90a5c9
                Packit 90a5c9
                        
              4. Packit 90a5c9
                          You can perform integer comparisons:
                Packit 90a5c9
                          
                Packit 90a5c9
                Packit 90a5c9
                            
                -eq
                Packit 90a5c9
                            
                Is numerically equal to
                Packit 90a5c9
                            The TestString is treated as an integer, and is
                Packit 90a5c9
                            numerically compared to the CondPattern. True if
                Packit 90a5c9
                            the two are numerically equal.
                Packit 90a5c9
                Packit 90a5c9
                            
                -ge
                Packit 90a5c9
                            
                Is numerically greater than or equal to
                Packit 90a5c9
                            The TestString is treated as an integer, and is
                Packit 90a5c9
                            numerically compared to the CondPattern. True if
                Packit 90a5c9
                            the TestString is numerically greater than or equal
                Packit 90a5c9
                            to the CondPattern.
                Packit 90a5c9
                Packit 90a5c9
                            
                -gt
                Packit 90a5c9
                            
                Is numerically greater than
                Packit 90a5c9
                            The TestString is treated as an integer, and is
                Packit 90a5c9
                            numerically compared to the CondPattern. True if
                Packit 90a5c9
                            the TestString is numerically greater than
                Packit 90a5c9
                            the CondPattern.
                Packit 90a5c9
                Packit 90a5c9
                            
                -le
                Packit 90a5c9
                            
                Is numerically less than or equal to
                Packit 90a5c9
                            The TestString is treated as an integer, and is
                Packit 90a5c9
                            numerically compared to the CondPattern. True if
                Packit 90a5c9
                            the TestString is numerically less than or equal
                Packit 90a5c9
                            to the CondPattern. Avoid confusion with the
                Packit 90a5c9
                            -l by using the -L or
                Packit 90a5c9
                            -h variant.
                Packit 90a5c9
                Packit 90a5c9
                            
                -lt
                Packit 90a5c9
                            
                Is numerically less than
                Packit 90a5c9
                            The TestString is treated as an integer, and is
                Packit 90a5c9
                            numerically compared to the CondPattern. True if
                Packit 90a5c9
                            the TestString is numerically less than
                Packit 90a5c9
                            the CondPattern. Avoid confusion with the
                Packit 90a5c9
                            -l by using the -L or
                Packit 90a5c9
                            -h variant.
                Packit 90a5c9
                Packit 90a5c9
                            
                -ne
                Packit 90a5c9
                            
                Is numerically not equal to
                Packit 90a5c9
                            The TestString is treated as an integer, and is
                Packit 90a5c9
                            numerically compared to the CondPattern. True if
                Packit 90a5c9
                            the two are numerically different. This is equivalent to
                Packit 90a5c9
                            !-eq.
                Packit 90a5c9
                Packit 90a5c9
                           
                Packit 90a5c9
                        
                Packit 90a5c9
                Packit 90a5c9
                        
              5. You can perform various file attribute tests:
              6. Packit 90a5c9
                Packit 90a5c9
                Packit 90a5c9
                          
                Packit 90a5c9
                Packit 90a5c9
                          
                -d
                Packit 90a5c9
                Packit 90a5c9
                          
                Is directory.
                Packit 90a5c9
                             Treats the TestString as a pathname and tests
                Packit 90a5c9
                            whether or not it exists, and is a directory.
                Packit 90a5c9
                          
                Packit 90a5c9
                Packit 90a5c9
                          
                -f
                Packit 90a5c9
                Packit 90a5c9
                          
                Is regular file.
                Packit 90a5c9
                Packit 90a5c9
                             Treats the TestString as a pathname and tests
                Packit 90a5c9
                            whether or not it exists, and is a regular file.
                Packit 90a5c9
                        
                Packit 90a5c9
                Packit 90a5c9
                           
                -F
                Packit 90a5c9
                Packit 90a5c9
                           
                Is existing file, via subrequest.
                Packit 90a5c9
                            Checks whether or not TestString is a valid file,
                Packit 90a5c9
                            accessible via all the server's currently-configured
                Packit 90a5c9
                            access controls for that path. This uses an internal
                Packit 90a5c9
                            subrequest to do the check, so use it with care -
                Packit 90a5c9
                            it can impact your server's performance!
                Packit 90a5c9
                           
                Packit 90a5c9
                Packit 90a5c9
                            
                -h
                Packit 90a5c9
                            
                Is symbolic link, bash convention.
                Packit 90a5c9
                            See -l.
                Packit 90a5c9
                            
                Packit 90a5c9
                Packit 90a5c9
                            
                -l
                Packit 90a5c9
                Packit 90a5c9
                            
                Is symbolic link.
                Packit 90a5c9
                            Treats the TestString as a pathname and tests
                Packit 90a5c9
                            whether or not it exists, and is a symbolic link. May also
                Packit 90a5c9
                            use the bash convention of -L or
                Packit 90a5c9
                            -h if there's a possibility of confusion
                Packit 90a5c9
                            such as when using the -lt or
                Packit 90a5c9
                            -le tests.
                Packit 90a5c9
                            
                Packit 90a5c9
                Packit 90a5c9
                            
                -L
                Packit 90a5c9
                            
                Is symbolic link, bash convention.
                Packit 90a5c9
                            See -l.
                Packit 90a5c9
                Packit 90a5c9
                            
                -s
                Packit 90a5c9
                            
                Is regular file, with size.
                Packit 90a5c9
                            Treats the TestString as a pathname and tests
                Packit 90a5c9
                            whether or not it exists, and is a regular file with size greater
                Packit 90a5c9
                            than zero.
                Packit 90a5c9
                Packit 90a5c9
                            
                -U
                Packit 90a5c9
                            

                Is existing URL, via subrequest.

                Packit 90a5c9
                            Checks whether or not TestString is a valid URL,
                Packit 90a5c9
                            accessible via all the server's currently-configured
                Packit 90a5c9
                            access controls for that path. This uses an internal
                Packit 90a5c9
                            subrequest to do the check, so use it with care -
                Packit 90a5c9
                            it can impact your server's performance!

                Packit 90a5c9
                            

                This flag only returns information about things

                Packit 90a5c9
                            like access control, authentication, and authorization.  This flag
                Packit 90a5c9
                            does not return information about the status code the
                Packit 90a5c9
                            configured handler (static file, CGI, proxy, etc.) would have
                Packit 90a5c9
                            returned.

                Packit 90a5c9
                Packit 90a5c9
                            
                -x
                Packit 90a5c9
                            
                Has executable permissions.
                Packit 90a5c9
                            Treats the TestString as a pathname and tests
                Packit 90a5c9
                            whether or not it exists, and has executable permissions.
                Packit 90a5c9
                            These permissions are determined according to
                Packit 90a5c9
                            the underlying OS.
                Packit 90a5c9
                Packit 90a5c9
                          
                Packit 90a5c9
                Packit 90a5c9
                          For example:
                Packit 90a5c9
                Packit 90a5c9
                        
                RewriteCond /var/www/%{REQUEST_URI} !-f
                Packit 90a5c9
                RewriteRule ^(.+) /other/archive/$1 [R]
                Packit 90a5c9
                Packit 90a5c9
                Packit 90a5c9
                        
                Packit 90a5c9
                Packit 90a5c9
                        
              7. Packit 90a5c9
                           

                If the TestString has the special value expr, the

                Packit 90a5c9
                           CondPattern will be treated as an
                Packit 90a5c9
                           ap_expr.

                Packit 90a5c9
                Packit 90a5c9
                           

                Packit 90a5c9
                            In the below example, -strmatch is used to
                Packit 90a5c9
                            compare the REFERER against the site hostname,
                Packit 90a5c9
                            to block unwanted hotlinking.
                Packit 90a5c9
                           

                Packit 90a5c9
                Packit 90a5c9
                           
                RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
                Packit 90a5c9
                RewriteRule "^/images" "-" [F]
                Packit 90a5c9
                Packit 90a5c9
                        
                Packit 90a5c9
                     
                Packit 90a5c9
                Packit 90a5c9
                     

                You can also set special flags for CondPattern by appending

                Packit 90a5c9
                        [flags]
                Packit 90a5c9
                      as the third argument to the RewriteCond
                Packit 90a5c9
                      directive, where flags is a comma-separated list of any of the
                Packit 90a5c9
                      following flags:

                Packit 90a5c9
                      
                Packit 90a5c9
                      
                  Packit 90a5c9
                          
                • 'nocase|NC'
                • Packit 90a5c9
                          (no case)
                  Packit 90a5c9
                          This makes the test case-insensitive - differences
                  Packit 90a5c9
                          between 'A-Z' and 'a-z' are ignored, both in the
                  Packit 90a5c9
                          expanded TestString and the CondPattern.
                  Packit 90a5c9
                          This flag is effective only for comparisons between
                  Packit 90a5c9
                          TestString and CondPattern. It has no
                  Packit 90a5c9
                          effect on filesystem and subrequest checks.
                  Packit 90a5c9
                  Packit 90a5c9
                          
                • Packit 90a5c9
                            'ornext|OR'
                  Packit 90a5c9
                            (or next condition)
                  Packit 90a5c9
                            Use this to combine rule conditions with a local OR
                  Packit 90a5c9
                            instead of the implicit AND. Typical example:
                  Packit 90a5c9
                  Packit 90a5c9
                  RewriteCond "%{REMOTE_HOST}"  "^host1"  [OR]
                  Packit 90a5c9
                  RewriteCond "%{REMOTE_HOST}"  "^host2"  [OR]
                  Packit 90a5c9
                  RewriteCond "%{REMOTE_HOST}"  "^host3"
                  Packit 90a5c9
                  RewriteRule ...some special stuff for any of these hosts...
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                            Without this flag you would have to write the condition/rule
                  Packit 90a5c9
                            pair three times.
                  Packit 90a5c9
                          
                  Packit 90a5c9
                  Packit 90a5c9
                          
                • 'novary|NV'
                • Packit 90a5c9
                          (no vary)
                  Packit 90a5c9
                          If a HTTP header is used in the condition, this flag prevents
                  Packit 90a5c9
                          this header from being added to the Vary header of the response. 
                  Packit 90a5c9
                          Using this flag might break proper caching of the response if
                  Packit 90a5c9
                          the representation of this response varies on the value of this header.
                  Packit 90a5c9
                          So this flag should be only used if the meaning of the Vary header
                  Packit 90a5c9
                          is well understood.
                  Packit 90a5c9
                          
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Example:

                  Packit 90a5c9
                  Packit 90a5c9
                         

                  To rewrite the Homepage of a site according to the

                  Packit 90a5c9
                          ``User-Agent:'' header of the request, you can
                  Packit 90a5c9
                          use the following: 

                  Packit 90a5c9
                  Packit 90a5c9
                  RewriteCond  "%{HTTP_USER_AGENT}"  "(iPhone|Blackberry|Android)"
                  Packit 90a5c9
                  RewriteRule  "^/$"                 "/homepage.mobile.html"  [L]
                  Packit 90a5c9
                  Packit 90a5c9
                  RewriteRule  "^/$"                 "/homepage.std.html"     [L]
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                          

                  Explanation: If you use a browser which identifies itself

                  Packit 90a5c9
                          as a mobile browser (note that the example is incomplete, as
                  Packit 90a5c9
                          there are many other mobile platforms), the mobile version of
                  Packit 90a5c9
                          the homepage is served. Otherwise, the standard page is served.
                  Packit 90a5c9
                          

                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  top
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Description:Enables or disables runtime rewriting engine
                  Packit 90a5c9
                  Syntax:RewriteEngine on|off
                  Packit 90a5c9
                  Default:RewriteEngine off
                  Packit 90a5c9
                  Context:server config, virtual host, directory, .htaccess
                  Packit 90a5c9
                  Override:FileInfo
                  Packit 90a5c9
                  Status:Extension
                  Packit 90a5c9
                  Module:mod_rewrite
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The RewriteEngine directive enables or

                  Packit 90a5c9
                        disables the runtime rewriting engine. If it is set to
                  Packit 90a5c9
                        off this module does no runtime processing at
                  Packit 90a5c9
                        all. It does not even update the SCRIPT_URx
                  Packit 90a5c9
                        environment variables.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Use this directive to disable rules in a particular context,

                  Packit 90a5c9
                        rather than commenting out all the RewriteRule directives.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Note that rewrite configurations are not

                  Packit 90a5c9
                        inherited by virtual hosts. This means that you need to have a
                  Packit 90a5c9
                        RewriteEngine on directive for each virtual host
                  Packit 90a5c9
                        in which you wish to use rewrite rules.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  RewriteMap directives

                  Packit 90a5c9
                        of the type prg
                  Packit 90a5c9
                        are not started during server initialization if they're defined in a
                  Packit 90a5c9
                        context that does not have RewriteEngine set to
                  Packit 90a5c9
                        on

                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  top
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Description:Defines a mapping function for key-lookup
                  Packit 90a5c9
                  Syntax:RewriteMap MapName MapType:MapSource
                  Packit 90a5c9
                      [MapTypeOptions]
                  Packit 90a5c9
                  Packit 90a5c9
                  Context:server config, virtual host
                  Packit 90a5c9
                  Status:Extension
                  Packit 90a5c9
                  Module:mod_rewrite
                  Packit 90a5c9
                  Compatibility:The 3rd parameter, MapTypeOptions, in only available from Apache
                  Packit 90a5c9
                  2.4.29 and later
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The RewriteMap directive defines a

                  Packit 90a5c9
                        Rewriting Map which can be used inside rule
                  Packit 90a5c9
                        substitution strings by the mapping-functions to
                  Packit 90a5c9
                        insert/substitute fields through a key lookup. The source of
                  Packit 90a5c9
                        this lookup can be of various types.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The MapName is

                  Packit 90a5c9
                        the name of the map and will be used to specify a
                  Packit 90a5c9
                        mapping-function for the substitution strings of a rewriting
                  Packit 90a5c9
                        rule via one of the following constructs:

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Packit 90a5c9
                          ${ MapName :
                  Packit 90a5c9
                          LookupKey }
                  Packit 90a5c9
                           ${ MapName :
                  Packit 90a5c9
                          LookupKey | DefaultValue
                  Packit 90a5c9
                          }
                  Packit 90a5c9
                        

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  When such a construct occurs, the map MapName is

                  Packit 90a5c9
                        consulted and the key LookupKey is looked-up. If the
                  Packit 90a5c9
                        key is found, the map-function construct is substituted by
                  Packit 90a5c9
                        SubstValue. If the key is not found then it is
                  Packit 90a5c9
                        substituted by DefaultValue or by the empty string
                  Packit 90a5c9
                        if no DefaultValue was specified. Empty values
                  Packit 90a5c9
                        behave as if the key was absent, therefore it is not possible
                  Packit 90a5c9
                        to distinguish between empty-valued keys and absent keys.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  For example, you might define a

                  Packit 90a5c9
                        RewriteMap as:

                  Packit 90a5c9
                  Packit 90a5c9
                        
                  RewriteMap examplemap "txt:/path/to/file/map.txt"
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  You would then be able to use this map in a

                  Packit 90a5c9
                        RewriteRule as follows:

                  Packit 90a5c9
                  Packit 90a5c9
                        
                  RewriteRule "^/ex/(.*)" "${examplemap:$1}"
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The meaning of the MapTypeOptions argument depends on

                  Packit 90a5c9
                        particular MapType. See the
                  Packit 90a5c9
                        Using RewriteMap for
                  Packit 90a5c9
                        more information.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The following combinations for MapType and

                  Packit 90a5c9
                        MapSource can be used:

                  Packit 90a5c9
                  Packit 90a5c9
                      
                  Packit 90a5c9
                  Packit 90a5c9
                      
                  txt
                  Packit 90a5c9
                          
                  A plain text file containing space-separated key-value
                  Packit 90a5c9
                          pairs, one per line. (Details ...)
                  Packit 90a5c9
                  Packit 90a5c9
                      
                  rnd
                  Packit 90a5c9
                          
                  Randomly selects an entry from a plain text file (Details ...)
                  Packit 90a5c9
                  Packit 90a5c9
                      
                  dbm
                  Packit 90a5c9
                          
                  Looks up an entry in a dbm file containing name, value
                  Packit 90a5c9
                          pairs. Hash is constructed from a plain text file format using
                  Packit 90a5c9
                          the httxt2dbm
                  Packit 90a5c9
                          utility.  (Details ...)
                  Packit 90a5c9
                  Packit 90a5c9
                      
                  int
                  Packit 90a5c9
                          
                  One of the four available internal functions provided by
                  Packit 90a5c9
                          RewriteMap: toupper, tolower, escape or
                  Packit 90a5c9
                          unescape. (Details ...)
                  Packit 90a5c9
                  Packit 90a5c9
                      
                  prg
                  Packit 90a5c9
                          
                  Calls an external program or script to process the
                  Packit 90a5c9
                          rewriting. (Details ...)
                  Packit 90a5c9
                  Packit 90a5c9
                      
                  dbd or fastdbd
                  Packit 90a5c9
                          
                  A SQL SELECT statement to be performed to look up the
                  Packit 90a5c9
                          rewrite target. (Details ...)
                  Packit 90a5c9
                      
                  Packit 90a5c9
                  Packit 90a5c9
                      

                  Further details, and numerous examples, may be found in the RewriteMap HowTo

                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  top
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Description:Sets some special options for the rewrite engine
                  Packit 90a5c9
                  Syntax:RewriteOptions Options
                  Packit 90a5c9
                  Context:server config, virtual host, directory, .htaccess
                  Packit 90a5c9
                  Override:FileInfo
                  Packit 90a5c9
                  Status:Extension
                  Packit 90a5c9
                  Module:mod_rewrite
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The RewriteOptions directive sets some

                  Packit 90a5c9
                        special options for the current per-server or per-directory
                  Packit 90a5c9
                        configuration. The Option string can currently
                  Packit 90a5c9
                        only be one of the following:

                  Packit 90a5c9
                  Packit 90a5c9
                        
                  Packit 90a5c9
                        
                  Inherit
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  This forces the current configuration to inherit the

                  Packit 90a5c9
                        configuration of the parent. In per-virtual-server context,
                  Packit 90a5c9
                        this means that the maps, conditions and rules of the main
                  Packit 90a5c9
                        server are inherited. In per-directory context this means
                  Packit 90a5c9
                        that conditions and rules of the parent directory's
                  Packit 90a5c9
                        .htaccess configuration or
                  Packit 90a5c9
                        <Directory>
                  Packit 90a5c9
                        sections are inherited. The inherited rules are virtually copied
                  Packit 90a5c9
                        to the section where this directive is being used. If used in
                  Packit 90a5c9
                        combination with local rules, the inherited rules are copied behind
                  Packit 90a5c9
                        the local rules. The position of this directive - below or above
                  Packit 90a5c9
                        of local rules - has no influence on this behavior. If local
                  Packit 90a5c9
                        rules forced the rewriting to stop, the inherited rules won't
                  Packit 90a5c9
                        be processed.

                  Packit 90a5c9
                  Packit 90a5c9
                        
                  Packit 90a5c9
                        Rules inherited from the parent scope are applied
                  Packit 90a5c9
                        after rules specified in the child scope.
                  Packit 90a5c9
                        
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  InheritBefore
                  Packit 90a5c9
                        
                  Packit 90a5c9
                        

                  Like Inherit above, but the rules from the parent scope

                  Packit 90a5c9
                        are applied before rules specified in the child scope.
                  Packit 90a5c9
                        Available in Apache HTTP Server 2.3.10 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  InheritDown
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  If this option is enabled, all child configurations will inherit

                  Packit 90a5c9
                        the configuration of the current configuration. It is equivalent to
                  Packit 90a5c9
                        specifying RewriteOptions Inherit in all child
                  Packit 90a5c9
                        configurations. See the Inherit option for more details
                  Packit 90a5c9
                        on how the parent-child relationships are handled.
                  Packit 90a5c9
                        Available in Apache HTTP Server 2.4.8 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  InheritDownBefore
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Like InheritDown above, but the rules from the current

                  Packit 90a5c9
                        scope are applied before rules specified in any child's
                  Packit 90a5c9
                        scope.
                  Packit 90a5c9
                        Available in Apache HTTP Server 2.4.8 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  IgnoreInherit
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  This option forces the current and child configurations to ignore

                  Packit 90a5c9
                        all rules that would be inherited from a parent specifying
                  Packit 90a5c9
                        InheritDown or InheritDownBefore.
                  Packit 90a5c9
                        Available in Apache HTTP Server 2.4.8 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  AllowNoSlash
                  Packit 90a5c9
                        
                  Packit 90a5c9
                        

                  By default, mod_rewrite will ignore URLs that map to a

                  Packit 90a5c9
                        directory on disk but lack a trailing slash, in the expectation that
                  Packit 90a5c9
                        the mod_dir module will issue the client with a redirect to
                  Packit 90a5c9
                        the canonical URL with a trailing slash.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  When the DirectorySlash directive

                  Packit 90a5c9
                        is set to off, the AllowNoSlash option can be enabled to ensure
                  Packit 90a5c9
                        that rewrite rules are no longer ignored. This option makes it possible to
                  Packit 90a5c9
                        apply rewrite rules within .htaccess files that match the directory without
                  Packit 90a5c9
                        a trailing slash, if so desired.
                  Packit 90a5c9
                        Available in Apache HTTP Server 2.4.0 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  AllowAnyURI
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  When RewriteRule

                  Packit 90a5c9
                        is used in VirtualHost or server context with
                  Packit 90a5c9
                        version 2.2.22 or later of httpd, mod_rewrite
                  Packit 90a5c9
                        will only process the rewrite rules if the request URI is a URL-path.  This avoids
                  Packit 90a5c9
                        some security issues where particular rules could allow
                  Packit 90a5c9
                        "surprising" pattern expansions (see CVE-2011-3368
                  Packit 90a5c9
                        and CVE-2011-4317).
                  Packit 90a5c9
                        To lift the restriction on matching a URL-path, the
                  Packit 90a5c9
                        AllowAnyURI option can be enabled, and
                  Packit 90a5c9
                        mod_rewrite will apply the rule set to any
                  Packit 90a5c9
                        request URI string, regardless of whether that string matches
                  Packit 90a5c9
                        the URL-path grammar required by the HTTP specification.
                  Packit 90a5c9
                        Available in Apache HTTP Server 2.4.3 and later.

                  Packit 90a5c9
                  Packit 90a5c9
                        
                  Packit 90a5c9
                        

                  Security Warning

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Enabling this option will make the server vulnerable to

                  Packit 90a5c9
                        security issues if used with rewrite rules which are not
                  Packit 90a5c9
                        carefully authored.  It is strongly recommended
                  Packit 90a5c9
                        that this option is not used.  In particular, beware of input
                  Packit 90a5c9
                        strings containing the '@' character which could
                  Packit 90a5c9
                        change the interpretation of the transformed URI, as per the
                  Packit 90a5c9
                        above CVE names.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  MergeBase
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  With this option, the value of RewriteBase is copied from where it's explicitly defined

                  Packit 90a5c9
                        into any sub-directory or sub-location that doesn't define its own
                  Packit 90a5c9
                        RewriteBase. This was the
                  Packit 90a5c9
                        default behavior in 2.4.0 through 2.4.3, and the flag to restore it is
                  Packit 90a5c9
                        available Apache HTTP Server 2.4.4 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  IgnoreContextInfo
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  When a relative substitution is made

                  Packit 90a5c9
                           in directory (htaccess) context and RewriteBase has not been set, this module uses some
                  Packit 90a5c9
                           extended URL and filesystem context information to change the
                  Packit 90a5c9
                           relative substitution back into a URL. Modules such as
                  Packit 90a5c9
                           mod_userdir and mod_alias
                  Packit 90a5c9
                           supply this extended context info.  Available in 2.4.16 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  LegacyPrefixDocRoot
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Prior to 2.4.26, if a substitution was an absolute URL that matched

                  Packit 90a5c9
                           the current virtual host, the URL might first be reduced to a URL-path
                  Packit 90a5c9
                           and then later reduced to a local path. Since the URL can be reduced 
                  Packit 90a5c9
                           to a local path, the path should be prefixed with the document root. 
                  Packit 90a5c9
                           This prevents a file such as /tmp/myfile from being accessed when a 
                  Packit 90a5c9
                           request is made to http://host/file/myfile with the following 
                  Packit 90a5c9
                           RewriteRule.

                  Packit 90a5c9
                        
                  RewriteRule /file/(.*) http://localhost/tmp/$1
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  This option allows the old behavior to be used where the document

                  Packit 90a5c9
                           root is not prefixed to a local path that was reduced from a 
                  Packit 90a5c9
                           URL.  Available in 2.4.26 and later.

                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                        
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  top
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Description:Defines rules for the rewriting engine
                  Packit 90a5c9
                  Syntax:RewriteRule
                  Packit 90a5c9
                        Pattern Substitution [flags]
                  Packit 90a5c9
                  Context:server config, virtual host, directory, .htaccess
                  Packit 90a5c9
                  Override:FileInfo
                  Packit 90a5c9
                  Status:Extension
                  Packit 90a5c9
                  Module:mod_rewrite
                  Packit 90a5c9
                  Packit 90a5c9
                        

                  The RewriteRule directive is the real

                  Packit 90a5c9
                        rewriting workhorse. The directive can occur more than once,
                  Packit 90a5c9
                        with each instance defining a single rewrite rule. The
                  Packit 90a5c9
                        order in which these rules are defined is important - this is the order
                  Packit 90a5c9
                        in which they will be applied at run-time.

                  Packit 90a5c9
                  Packit 90a5c9
                        

                  Pattern is

                  Packit 90a5c9
                        a perl compatible regular
                  Packit 90a5c9
                        expression.  What this pattern is compared against varies depending
                  Packit 90a5c9
                        on where the RewriteRule directive is defined. 

                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                  Packit 90a5c9
                    Packit 90a5c9
                          
                  • In VirtualHost context,

                  • Packit 90a5c9
                          The Pattern will initially be matched against the part of the
                    Packit 90a5c9
                          URL after the hostname and port, and before the query string (e.g. "/app1/index.html").
                    Packit 90a5c9
                          This is the (%-decoded) URL-path.

                    Packit 90a5c9
                    Packit 90a5c9
                          
                  • In per-directory context (Directory and .htaccess),

                  • Packit 90a5c9
                          the Pattern is matched against only a partial path, for example a request
                    Packit 90a5c9
                          of "/app1/index.html" may result in comparison against "app1/index.html" 
                    Packit 90a5c9
                          or "index.html" depending on where the RewriteRule is 
                    Packit 90a5c9
                          defined.

                    Packit 90a5c9
                    Packit 90a5c9
                          

                    The directory path where the rule is defined is stripped from the currently mapped

                    Packit 90a5c9
                          filesystem path before comparison (up to and including a trailing slash). 
                    Packit 90a5c9
                          The net result of this per-directory prefix stripping is that rules in
                    Packit 90a5c9
                          this context only match against the portion of the currently mapped filesystem path 
                    Packit 90a5c9
                          "below" where the rule is defined.

                    Packit 90a5c9
                    Packit 90a5c9
                          

                    Directives such as DocumentRoot and Alias, or even the

                    Packit 90a5c9
                          result of previous RewriteRule substitutions, determine
                    Packit 90a5c9
                          the currently mapped filesystem path.  
                    Packit 90a5c9
                          

                    Packit 90a5c9
                          
                    Packit 90a5c9
                    Packit 90a5c9
                          
                  • If you wish to match against the hostname, port, or query string, use a

                  • Packit 90a5c9
                          RewriteCond with the
                    Packit 90a5c9
                          %{HTTP_HOST}, %{SERVER_PORT}, or
                    Packit 90a5c9
                          %{QUERY_STRING} variables respectively.

                    Packit 90a5c9
                    Packit 90a5c9
                    Packit 90a5c9
                    Packit 90a5c9

                    Per-directory Rewrites

                    Packit 90a5c9
                      Packit 90a5c9
                    • The rewrite engine may be used in .htaccess files and in <Directory> sections, with some additional
                    • Packit 90a5c9
                      complexity.
                      Packit 90a5c9
                      Packit 90a5c9
                    • To enable the rewrite engine in this context, you need to set
                    • Packit 90a5c9
                      "RewriteEngine On" and
                      Packit 90a5c9
                      "Options FollowSymLinks" must be enabled. If your
                      Packit 90a5c9
                      administrator has disabled override of FollowSymLinks for
                      Packit 90a5c9
                      a user's directory, then you cannot use the rewrite engine. This
                      Packit 90a5c9
                      restriction is required for security reasons.
                      Packit 90a5c9
                      Packit 90a5c9
                    • See the RewriteBase
                    • Packit 90a5c9
                      directive for more information regarding what prefix will be added back to
                      Packit 90a5c9
                      relative substitutions.
                      Packit 90a5c9
                      Packit 90a5c9
                    • If you wish to match against the full URL-path in a per-directory
                    • Packit 90a5c9
                      (htaccess) RewriteRule, use the %{REQUEST_URI} variable in
                      Packit 90a5c9
                      a RewriteCond.
                      Packit 90a5c9
                      Packit 90a5c9
                    • The removed prefix always ends with a slash, meaning the matching occurs against a string which
                    • Packit 90a5c9
                      never has a leading slash.  Therefore, a Pattern with ^/ never
                      Packit 90a5c9
                      matches in per-directory context.
                      Packit 90a5c9
                      Packit 90a5c9
                    • Although rewrite rules are syntactically permitted in <Location> and <Files> sections
                    • Packit 90a5c9
                      (including their regular expression counterparts), this
                      Packit 90a5c9
                      should never be necessary and is unsupported. A likely feature
                      Packit 90a5c9
                      to break in these contexts is relative substitutions.
                      Packit 90a5c9
                      Packit 90a5c9
                      Packit 90a5c9
                      Packit 90a5c9
                            

                      For some hints on regular

                      Packit 90a5c9
                            expressions, see
                      Packit 90a5c9
                            the mod_rewrite
                      Packit 90a5c9
                            Introduction.

                      Packit 90a5c9
                      Packit 90a5c9
                            

                      In mod_rewrite, the NOT character

                      Packit 90a5c9
                            ('!') is also available as a possible pattern
                      Packit 90a5c9
                            prefix. This enables you to negate a pattern; to say, for instance:
                      Packit 90a5c9
                            ``if the current URL does NOT match this
                      Packit 90a5c9
                            pattern''. This can be used for exceptional cases, where
                      Packit 90a5c9
                            it is easier to match the negative pattern, or as a last
                      Packit 90a5c9
                            default rule.

                      Packit 90a5c9
                      Packit 90a5c9

                      Note

                      Packit 90a5c9
                      When using the NOT character to negate a pattern, you cannot include
                      Packit 90a5c9
                      grouped wildcard parts in that pattern. This is because, when the
                      Packit 90a5c9
                      pattern does NOT match (ie, the negation matches), there are no
                      Packit 90a5c9
                      contents for the groups. Thus, if negated patterns are used, you
                      Packit 90a5c9
                      cannot use $N in the substitution string!
                      Packit 90a5c9
                      Packit 90a5c9
                      Packit 90a5c9
                            

                      The Substitution of a

                      Packit 90a5c9
                            rewrite rule is the string that replaces the original URL-path that
                      Packit 90a5c9
                            was matched by Pattern.  The Substitution may
                      Packit 90a5c9
                            be a:

                      Packit 90a5c9
                      Packit 90a5c9
                            
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      file-system path
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      Designates the location on the file-system of the resource
                      Packit 90a5c9
                              to be delivered to the client.  Substitutions are only
                      Packit 90a5c9
                              treated as a file-system path when the rule is configured in
                      Packit 90a5c9
                              server (virtualhost) context and the first component of the
                      Packit 90a5c9
                              path in the substitution exists in the file-system
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      URL-path
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      A DocumentRoot-relative path to the
                      Packit 90a5c9
                              resource to be served. Note that mod_rewrite
                      Packit 90a5c9
                              tries to guess whether you have specified a file-system path
                      Packit 90a5c9
                              or a URL-path by checking to see if the first segment of the
                      Packit 90a5c9
                              path exists at the root of the file-system. For example, if
                      Packit 90a5c9
                              you specify a Substitution string of
                      Packit 90a5c9
                              /www/file.html, then this will be treated as a
                      Packit 90a5c9
                              URL-path unless a directory named www
                      Packit 90a5c9
                              exists at the root or your file-system (or, in the case of
                      Packit 90a5c9
                              using rewrites in a .htaccess file, relative to
                      Packit 90a5c9
                              your document root), in which case it will
                      Packit 90a5c9
                              be treated as a file-system path. If you wish other
                      Packit 90a5c9
                              URL-mapping directives (such as Alias) to be applied to the
                      Packit 90a5c9
                              resulting URL-path, use the [PT] flag as
                      Packit 90a5c9
                              described below.
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      Absolute URL
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      If an absolute URL is specified,
                      Packit 90a5c9
                              mod_rewrite checks to see whether the
                      Packit 90a5c9
                              hostname matches the current host. If it does, the scheme and
                      Packit 90a5c9
                              hostname are stripped out and the resulting path is treated as
                      Packit 90a5c9
                              a URL-path. Otherwise, an external redirect is performed for
                      Packit 90a5c9
                              the given URL. To force an external redirect back to the
                      Packit 90a5c9
                              current host, see the [R] flag below.
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      - (dash)
                      Packit 90a5c9
                      Packit 90a5c9
                              
                      A dash indicates that no substitution should be performed
                      Packit 90a5c9
                              (the existing path is passed through untouched). This is used
                      Packit 90a5c9
                              when a flag (see below) needs to be applied without changing
                      Packit 90a5c9
                              the path.
                      Packit 90a5c9
                      Packit 90a5c9
                            
                      Packit 90a5c9
                      Packit 90a5c9
                            

                      In addition to plain text, the Substitution string can include

                      Packit 90a5c9
                      Packit 90a5c9
                            
                        Packit 90a5c9
                                
                      1. back-references ($N) to the RewriteRule
                      2. Packit 90a5c9
                                pattern
                        Packit 90a5c9
                        Packit 90a5c9
                                
                      3. back-references (%N) to the last matched
                      4. Packit 90a5c9
                                RewriteCond pattern
                        Packit 90a5c9
                        Packit 90a5c9
                                
                      5. server-variables as in rule condition test-strings
                      6. Packit 90a5c9
                                (%{VARNAME})
                        Packit 90a5c9
                        Packit 90a5c9
                                
                      7. mapping-function calls
                      8. Packit 90a5c9
                                (${mapname:key|default})
                        Packit 90a5c9
                              
                        Packit 90a5c9
                        Packit 90a5c9
                              

                        Back-references are identifiers of the form

                        Packit 90a5c9
                              $N
                        Packit 90a5c9
                              (N=0..9), which will be replaced
                        Packit 90a5c9
                              by the contents of the Nth group of the
                        Packit 90a5c9
                              matched Pattern. The server-variables are the same
                        Packit 90a5c9
                              as for the TestString of a
                        Packit 90a5c9
                              RewriteCond
                        Packit 90a5c9
                              directive. The mapping-functions come from the
                        Packit 90a5c9
                              RewriteMap
                        Packit 90a5c9
                              directive and are explained there.
                        Packit 90a5c9
                              These three types of variables are expanded in the order above.

                        Packit 90a5c9
                        Packit 90a5c9
                              

                        Rewrite rules are applied to the results of previous rewrite

                        Packit 90a5c9
                              rules, in the order in which they are defined
                        Packit 90a5c9
                              in the config file. The URL-path or file-system path (see "What is matched?", above) is completely
                        Packit 90a5c9
                              replaced by the Substitution and the
                        Packit 90a5c9
                              rewriting process continues until all rules have been applied,
                        Packit 90a5c9
                              or it is explicitly terminated by an
                        Packit 90a5c9
                              L flag,
                        Packit 90a5c9
                              or other flag which implies immediate termination, such as
                        Packit 90a5c9
                              END or
                        Packit 90a5c9
                              F.

                        Packit 90a5c9
                        Packit 90a5c9
                             

                        Modifying the Query String

                        Packit 90a5c9
                              

                        By default, the query string is passed through unchanged. You

                        Packit 90a5c9
                              can, however, create URLs in the substitution string containing
                        Packit 90a5c9
                              a query string part. Simply use a question mark inside the
                        Packit 90a5c9
                              substitution string to indicate that the following text should
                        Packit 90a5c9
                              be re-injected into the query string. When you want to erase an
                        Packit 90a5c9
                              existing query string, end the substitution string with just a
                        Packit 90a5c9
                              question mark. To combine new and old query strings, use the
                        Packit 90a5c9
                              [QSA] flag.

                        Packit 90a5c9
                             
                        Packit 90a5c9
                        Packit 90a5c9
                              

                        Additionally you can set special actions to be performed by

                        Packit 90a5c9
                              appending [flags]
                        Packit 90a5c9
                              as the third argument to the RewriteRule
                        Packit 90a5c9
                              directive. Flags is a comma-separated list, surround by square
                        Packit 90a5c9
                              brackets, of any of the flags in the following table. More
                        Packit 90a5c9
                              details, and examples, for each flag, are available in the Rewrite Flags document.

                        Packit 90a5c9
                        Packit 90a5c9
                            
                        Flag and syntax
                        Packit 90a5c9
                                Function
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                B
                        Packit 90a5c9
                                Escape non-alphanumeric characters in backreferences before
                        Packit 90a5c9
                                applying the transformation. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                backrefnoplus|BNP
                        Packit 90a5c9
                                If backreferences are being escaped, spaces should be escaped to
                        Packit 90a5c9
                                %20 instead of +. Useful when the backreference will be used in the
                        Packit 90a5c9
                                path component rather than the query string.details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                chain|C
                        Packit 90a5c9
                                Rule is chained to the following rule. If the rule fails,
                        Packit 90a5c9
                                the rule(s) chained to it will be skipped. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                cookie|CO=NAME:VAL
                        Packit 90a5c9
                                Sets a cookie in the client browser. Full syntax is:
                        Packit 90a5c9
                                CO=NAME:VAL:domain[:lifetime[:path[:secure[:httponly]]]] details ...
                        Packit 90a5c9
                                
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                discardpath|DPI
                        Packit 90a5c9
                                Causes the PATH_INFO portion of the rewritten URI to be
                        Packit 90a5c9
                                discarded. details
                        Packit 90a5c9
                                ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                END
                        Packit 90a5c9
                                Stop the rewriting process immediately and don't apply any
                        Packit 90a5c9
                                more rules. Also prevents further execution of rewrite rules
                        Packit 90a5c9
                                in per-directory and .htaccess context. (Available in 2.3.9 and later)
                        Packit 90a5c9
                                details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                env|E=[!]VAR[:VAL]
                        Packit 90a5c9
                                Causes an environment variable VAR to be set (to the
                        Packit 90a5c9
                                value VAL if provided). The form !VAR causes
                        Packit 90a5c9
                                the environment variable VAR to be unset.
                        Packit 90a5c9
                                details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                forbidden|F
                        Packit 90a5c9
                                Returns a 403 FORBIDDEN response to the client browser.
                        Packit 90a5c9
                                details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                gone|G
                        Packit 90a5c9
                                Returns a 410 GONE response to the client browser. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                Handler|H=Content-handler
                        Packit 90a5c9
                                Causes the resulting URI to be sent to the specified
                        Packit 90a5c9
                                Content-handler for processing. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                last|L
                        Packit 90a5c9
                                Stop the rewriting process immediately and don't apply any
                        Packit 90a5c9
                                more rules. Especially note caveats for per-directory and
                        Packit 90a5c9
                                .htaccess context (see also the END flag). details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                next|N
                        Packit 90a5c9
                                Re-run the rewriting process, starting again with the first
                        Packit 90a5c9
                                rule, using the result of the ruleset so far as a starting
                        Packit 90a5c9
                                point. details
                        Packit 90a5c9
                                ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                nocase|NC
                        Packit 90a5c9
                                Makes the pattern comparison case-insensitive.
                        Packit 90a5c9
                                details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                noescape|NE
                        Packit 90a5c9
                                Prevent mod_rewrite from applying hexcode escaping of
                        Packit 90a5c9
                                special characters in the result of the rewrite. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                nosubreq|NS
                        Packit 90a5c9
                                Causes a rule to be skipped if the current request is an
                        Packit 90a5c9
                                internal sub-request. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                proxy|P
                        Packit 90a5c9
                                Force the substitution URL to be internally sent as a proxy
                        Packit 90a5c9
                                request. details
                        Packit 90a5c9
                                ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                passthrough|PT
                        Packit 90a5c9
                                Forces the resulting URI to be passed back to the URL
                        Packit 90a5c9
                                mapping engine for processing of other URI-to-filename
                        Packit 90a5c9
                                translators, such as Alias or
                        Packit 90a5c9
                                Redirect. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                qsappend|QSA
                        Packit 90a5c9
                                Appends any query string from the original request URL to
                        Packit 90a5c9
                                any query string created in the rewrite target.details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                qsdiscard|QSD
                        Packit 90a5c9
                                Discard any query string attached to the incoming URI.
                        Packit 90a5c9
                                details
                        Packit 90a5c9
                                ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                qslast|QSL
                        Packit 90a5c9
                                Interpret the last (right-most) question mark as the query string
                        Packit 90a5c9
                                    delimiter, instead of the first (left-most) as normally used.  
                        Packit 90a5c9
                                    Available in 2.4.19 and later.
                        Packit 90a5c9
                                details
                        Packit 90a5c9
                                ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                redirect|R[=code]
                        Packit 90a5c9
                                Forces an external redirect, optionally with the specified
                        Packit 90a5c9
                                HTTP status code. details ...
                        Packit 90a5c9
                                
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                skip|S=num
                        Packit 90a5c9
                                Tells the rewriting engine to skip the next num
                        Packit 90a5c9
                                rules if the current rule matches. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                                type|T=MIME-type
                        Packit 90a5c9
                                Force the MIME-type of the target file
                        Packit 90a5c9
                                to be the specified type. details ...
                        Packit 90a5c9
                            
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9

                        Home directory expansion

                        Packit 90a5c9

                        When the substitution string begins with a string

                        Packit 90a5c9
                        resembling "/~user" (via explicit text or backreferences), mod_rewrite performs
                        Packit 90a5c9
                        home directory expansion independent of the presence or configuration
                        Packit 90a5c9
                        of mod_userdir.

                        Packit 90a5c9
                        Packit 90a5c9

                        This expansion does not occur when the PT

                        Packit 90a5c9
                        flag is used on the RewriteRule
                        Packit 90a5c9
                        directive.

                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                             

                        Here are all possible substitution combinations and their

                        Packit 90a5c9
                              meanings:

                        Packit 90a5c9
                        Packit 90a5c9
                              

                        Inside per-server configuration

                        Packit 90a5c9
                              (httpd.conf)
                        Packit 90a5c9
                               for request ``GET
                        Packit 90a5c9
                              /somepath/pathinfo'':
                        Packit 90a5c9
                              

                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        Given Rule
                        Packit 90a5c9
                        Resulting Substitution
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) otherpath$1
                        Packit 90a5c9
                        invalid, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) otherpath$1  [R]
                        Packit 90a5c9
                        invalid, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) otherpath$1  [P]
                        Packit 90a5c9
                        invalid, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) /otherpath$1
                        Packit 90a5c9
                        /otherpath/pathinfo
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) /otherpath$1 [R]
                        Packit 90a5c9
                        http://thishost/otherpath/pathinfo via external redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) /otherpath$1 [P]
                        Packit 90a5c9
                        doesn't make sense, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) http://thishost/otherpath$1
                        Packit 90a5c9
                        /otherpath/pathinfo
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) http://thishost/otherpath$1 [R]
                        Packit 90a5c9
                        http://thishost/otherpath/pathinfo via external redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) http://thishost/otherpath$1 [P]
                        Packit 90a5c9
                        doesn't make sense, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) http://otherhost/otherpath$1
                        Packit 90a5c9
                        http://otherhost/otherpath/pathinfo via external redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) http://otherhost/otherpath$1 [R]
                        Packit 90a5c9
                        http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^/somepath(.*) http://otherhost/otherpath$1 [P]
                        Packit 90a5c9
                        http://otherhost/otherpath/pathinfo via internal proxy
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                              

                        Inside per-directory configuration for

                        Packit 90a5c9
                              /somepath
                        Packit 90a5c9
                               (/physical/path/to/somepath/.htaccess, with
                        Packit 90a5c9
                              RewriteBase "/somepath")
                        Packit 90a5c9
                               for request ``GET
                        Packit 90a5c9
                              /somepath/localpath/pathinfo'':
                        Packit 90a5c9
                             

                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        Given Rule
                        Packit 90a5c9
                        Resulting Substitution
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) otherpath$1
                        Packit 90a5c9
                        /somepath/otherpath/pathinfo
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) otherpath$1  [R]
                        Packit 90a5c9
                        http://thishost/somepath/otherpath/pathinfo via external
                        Packit 90a5c9
                        redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) otherpath$1  [P]
                        Packit 90a5c9
                        doesn't make sense, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) /otherpath$1
                        Packit 90a5c9
                        /otherpath/pathinfo
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) /otherpath$1 [R]
                        Packit 90a5c9
                        http://thishost/otherpath/pathinfo via external redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) /otherpath$1 [P]
                        Packit 90a5c9
                        doesn't make sense, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) http://thishost/otherpath$1
                        Packit 90a5c9
                        /otherpath/pathinfo
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) http://thishost/otherpath$1 [R]
                        Packit 90a5c9
                        http://thishost/otherpath/pathinfo via external redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) http://thishost/otherpath$1 [P]
                        Packit 90a5c9
                        doesn't make sense, not supported
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) http://otherhost/otherpath$1
                        Packit 90a5c9
                        http://otherhost/otherpath/pathinfo via external redirection
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) http://otherhost/otherpath$1 [R]
                        Packit 90a5c9
                        http://otherhost/otherpath/pathinfo via external redirection (the [R] flag is redundant)
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        ^localpath(.*) http://otherhost/otherpath$1 [P]
                        Packit 90a5c9
                        http://otherhost/otherpath/pathinfo via internal proxy
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                          
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9
                        Packit 90a5c9

                        Available Languages:  en  |

                        Packit 90a5c9
                         fr 

                        Packit 90a5c9
                        top

                        Comments

                        Notice:
                        This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.
                        Packit 90a5c9
                        <script type="text/javascript">
                        Packit 90a5c9
                        var comments_shortname = 'httpd';
                        Packit 90a5c9
                        var comments_identifier = 'http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html';
                        Packit 90a5c9
                        (function(w, d) {
                        Packit 90a5c9
                            if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
                        Packit 90a5c9
                                d.write('
                        <\/div>');
                        Packit 90a5c9
                                var s = d.createElement('script');
                        Packit 90a5c9
                                s.type = 'text/javascript';
                        Packit 90a5c9
                                s.async = true;
                        Packit 90a5c9
                                s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
                        Packit 90a5c9
                                (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
                        Packit 90a5c9
                            }
                        Packit 90a5c9
                            else { 
                        Packit 90a5c9
                                d.write('
                        Comments are disabled for this page at the moment.<\/div>');
                        Packit 90a5c9
                            }
                        Packit 90a5c9
                        })(window, document);
                        Packit 90a5c9
                        //--></script>
                        Packit 90a5c9

                        Copyright 2018 The Apache Software Foundation.
                        Licensed under the Apache License, Version 2.0.

                        Packit 90a5c9

                        Modules | Directives | FAQ | Glossary | Sitemap

                        <script type="text/javascript">
                        Packit 90a5c9
                        if (typeof(prettyPrint) !== 'undefined') {
                        Packit 90a5c9
                            prettyPrint();
                        Packit 90a5c9
                        }
                        Packit 90a5c9
                        //--></script>
                        Packit 90a5c9
                        </body></html>