Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>&lt;IfModule mod_rewrite.c&gt;...&lt;/IfModule&gt;</code> block ensures that everything contained within that block is taken only into account if the <code>mod_rewrite</code> module is loaded. Otherwise you will either face a server error or all requests for URL rewriting will be ignored.</p> <p>The following two lines are conditions for the <code>RewriteRule</code> line which follows them. It means that the <code>RewriteRule</code> will be evaluated only if these two conditions are met.</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d </code></pre> <p>These lines simply state that rewriting (<code>RewriteRule</code> line) will occur only if there are no existing files or folders on the server which match the URI. If they do exist then they will be served instead, unless there is some other directive that prevents it, otherwise rewriting will occur.</p> <p>The last line will do the actual rewriting. It will take whatever is following the website domain name and append it to a rewritten request which will begin with <code>index.php/</code>.</p> <p>Here is an example.</p> <p>Lets say you make a request for <code>example.com/example-page.html</code>.</p> <p>If there is no existing file or folder in the virtual hosts root folder named <code>example-page.html</code> the rewrite rule at the end will rewrite the request to look like <code>example.com/index.php/example-page.html</code>.</p> <p>The main reason why applications rewrite requests like this is to ensure that they have a single point of entry, often called a bootstrap, which is considered to be a good practice from the security standpoint and also offers more granular control of requests.</p> <p>Here is in my opinion a <a href="https://code.tutsplus.com/tutorials/an-in-depth-guide-to-mod_rewrite-for-apache--net-6708" rel="nofollow noreferrer">very good beginner friendly tutorial</a> for <code>mod_rewrite</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