Reputation: 2512
I have seen a .htaccess file with contents as following
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
As I understand, the Rewrite conditions say that if the requested url is meant for a file with non zero size, or a symbolic link or a directory then do nothing. That is done by
RewriteRule ^.*$ - [NC,L]
, means if the above conditions are true then stop processing right there; otherwise invoke /index.php
and that is done using RewriteRule ^.*$ /index.php [NC,L]
.
My doubts are,
1.In the tutorial (Survive the deep end) I am reading, saying that:
namely if the URL refers to a file (with size greater than zero), directory or symbolic link. This makes sure your javascript, css, and other non-PHP files can be served directly even if centralised elsewhere and referenced only by symbolic links.
As all of the .php files are non zero size then how apache can know the difference between php files and non php files ?
2.Will the requested url will be passed to /index.php as an argument or will it only invoke /index.php ?
Upvotes: 0
Views: 1934
Reputation: 33148
It's the REQUEST_FILENAME conditions that check whether the requested file/directory/symlink exists. Answering your questions:
As all of the .php files are non zero size then how apache can know the difference between php files and non php files ?
Apache doesn't need to know the difference. Any files in the public folder of your application are served as-is, regardless of file type. All of the Zend Framework files, and your application code exists outside of the public folder.
Will the requested url will be passed to /index.php as an argument or will it only invoke /index.php ?
The requested URL will still be present in environment variables like $_SERVER['REQUEST_URI']
, so ZF (and most frameworks) use this to work out which part of the application should serve the request.
Upvotes: 2