What does this Rewrite rule mean?
The rewrite has two parts. The first one specifies that if the requested filename is a regular file with a size greater than 0 (-s
), a symbolic link (-l
) or a directory (-d
), rewrite to nowhere, eg. take no action. [NC,L]
means that the rule is non case sensitive and the last rule that these conditions match.
All other requests are forwarded to /vote/public/index.php
.
The purpose of this rewrite is that an actual, existing file can be fetched from the server without interference. Without the first rule, every file request (css and js files, images etc) would go to index.php
which would mess things up pretty badly.
Usually this is written in one declaration, though. You can negate the conditions, and then the [OR]
statemens can be taken out also:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /vote/public/index.php [NC,L]
This is equivalent to the original statement.
Related videos on Youtube
streetparade
Updated on April 16, 2022Comments
-
streetparade about 2 years
Im installing phpancake, there is a folder there shema like this
application/ install/ library/ public/ sql_schema/ install.html install.php
What does this rule mean?
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ /vote/public/index.php [NC,L]
-
Ashish Ranjan almost 7 years@Tatu Ulmanen: can you please explain what would
RewriteCond %{REQUEST_FILENAME} -f
mean? is it just the "size" that options-s
and-f
differ in? And also what would be regular files(not Binary?)? -
Ashish Ranjan almost 7 yearsfrom @Tatu Ulmanen's answer can you please explain what would
RewriteCond %{REQUEST_FILENAME} -f
mean? is it just the "size" that options-s
and-f
differ in? And also what would be regular files(not Binary?)?