views:

33

answers:

2

hello to all, i'm doing maintenance work on a cms and have found the following htaccess file:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
#RewriteBase /


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

i'm having trouble understanding it. the reason a went looking for the htaccess file is this: i placed some code in index.php (right now just printing some string to a file but eventually will do banner cycling) and i've noticed the string gets printed a few times when i load index.php. could that have some connection to the htaccess file?

thanx in advance for any input.

A: 

Request is for a file on the webserver, denies access to index.php

RewriteCond %{REQUEST_FILENAME} !-f

Request is for a physical directory on the webserver, denies access to index.php

RewriteCond %{REQUEST_FILENAME} !-d 

Any other than the above, redirects to index.php

RewriteRule ^(.*)$ index.php/$1 [L]
tricat
A: 

This simply checks whether a file exists (as a file -f, or directory -d). If it does not, it takes the address and passes it to index.php.

For instance if you ask for:

www.mysite.com/badfile.html

You will get:

www.mysite.com/index.php/badfile.html

This should have no effect on how the code in index.php runs. This only affects what happens when non-existent files and directories are requested.

Jeff B
thank you for answering. just to be clear - if badfile.htm is requested, will index.php be loaded again? - this would explain why thecode that prints to file runs a few times and not just on the initial loading of index.php.if so, every time a non-existant file or dir is requested, the homepage gets reloaded, which is ,well, strange to me, at least..this is the code in index.phpfile_put_contents($text_file, $_SERVER['PHP_SELF'],FILE_APPEND );and the output is:/itportal.co.il/index.php/itportal.co.il/index.php/uploads/76126568849640.png ...etc..
samoyed
If index.php requests badfile.html, then yes, index.php will be called again. Basically, it will be called for every non-existent file that index.php requests. This means you could end up with a loop of sorts, as the new call to index.php may request the bad file again.
Jeff B