Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The parts of the rewrite rule break down as follows:</p> <ol> <li><p>RewriteRule <br /> Indicates this line will be a rewrite rule, as opposed to a rewrite condition or one of the other rewrite engine directives</p></li> <li><p>^(.*)$ <br /> Matches all characters <code>(.*)</code> from the beggining <code>^</code> to the end <code>$</code> of the request</p></li> <li><p>/index.php/$1 <br /> The request will be re-written with the data matched by <code>(.*)</code> in the previous example being substituted for <code>$1</code>.</p></li> <li><p>[L] <br /> This tells mod_rewrite that if the pattern in step 2 matches, apply this rule as the "Last" rule, and don't apply anymore.</p></li> </ol> <p>The <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite documentation</a> is really comprehensive, but admittedly a lot to wade through to decode such a simple example.</p> <p>The net effect is that all requests will be routed through <code>index.php</code>, a pattern seen in many model-view-controller implementations for PHP. <code>index.php</code> can examine the requested URL segments (and potentially whether the request was made via GET or POST) and use this information to dynamically invoke a certain script, without the location of that script having to match the directory structure implied by the request URI.</p> <p>For example, <code>/users/john/files/index</code> might invoke the function <code>index('john')</code> in a file called <code>user_files.php</code> stored in a scripts directory. Without mod_rewrite, the more traditional URL would probably use an arguably less readable query string and invoke the file directly: <code>/user_files.php?action=index&amp;user=john</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload