What does this .htaccess code mean?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* ./index.php
I think i开发者_如何学Got means if the url doesn't match a file or directory on the server go to /index.php?
Can anybody confirm?
Yes is the short answer. But usually ./index.php
has an [L,QSA]
suffix/qualifier, so the query part of a URI request is also passed on to it.
What this is doing:
RewriteCond %{REQUEST_FILENAME} !-d
If it can't find a directory with the name
RewriteCond %{REQUEST_FILENAME} !-f
If it can't find a file with the name
RewriteRule .* ./index.php
Load the index.php next to the .htaccess file.
To answer Anthony's question regarding what would happen if it where removed1 2,
It would try and access the directory or file. If it fails, instead of defaulting to the index.php
it would simply give the default web servers 404 error.
Right now, it allows the application to either show the default page, or handle the request through it in some fashion.
精彩评论