Can anybody explain what this mod_rewrite rule does?
I am attempting to comment the file, however the code appears to condition the alternative of the items I believe it's doing
# Enable rewriting of URLs RewriteEngine on # Allow specified file types to be accessed # Thing to test = URL # Condition = not starting with RewriteCond $1 !^(index\.php|images|css|js|robots\.txt) # RewriteRule will only be performed if the preceeding RewriteCond is fulfilled # Remove index.php from all URLs # Pattern = anything (0 or more of any character) # Substitution = index.php + the rest of the URL RewriteRule ^(.*)$ /index.php/$1 [L]
The browser transmits a request towards the server (Apache, since you are using mod_rewrite):
Apache accepts this request and sees in the configuration files that you have set up it to pass through all demands through mod_rewrite. So, it transmits the string 'profile/edit' to mod_rewrite. Mod_rewrite then is applicable the guidelines you specified into it, which in turn transforms the request (in the manner I described during my previous publish) to 'index.php/profile/edit'. After mod_rewrite is performed, Apache continues processing the request, and sees 'oh, this person is asking for the file index.php'. Therefore it calls the php interpreter which in turn parses and executes index.php - and will get '/profile/edit' as arguments. The php code (CI inside your situation) parses these arguments and understands how to call the best module inside your application.
So essentially, it's a method to always call index.php, even if the url does not specify index.php. For the reason that way, index.php works because the front controller: it routes all demands right location inside your application.
^ = begin of line ( = begin group .* = any character, any number of times ) = end group
The $one in the 2nd part is changed through the group in part one.
Is a Symfony rule? The concept would be to pass the entire query string towards the index.php (the leading controller) like a parameter, to ensure that the leading controller can parse and route it.
When the URL doesn't begin with index.php or images or css or js or robots.txt, the string "/index.php/" is prefixed.
As index.php is most likely an executable php application, the index.php then can see the relaxation from the URL from the cgi atmosphere. (it's saved in $)