2010-02-08 132 views
0

我做维修工作的CMS,并已发现了下面的htaccess文件:htaccess的帮助需要

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


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

我无法理解它。 的原因去寻找htaccess文件是这样的: 我把一些代码在index.php文件(现在只是一些打印字符串的文件,但 最终会做旗帜循环),我已经注意到了字符串被打印的几次,当我加载index.php。可以有一些连接到htaccess文件?

thanx提前为任何输入。

+0

它不应该有任何连接。你可以添加你改变的代码吗(只有相关部分)?如果你回滚到原来的index.php,这个问题是否显示出来? – 2010-02-08 22:49:46

+0

thanx, 这是index.php中的相关代码: file_put_contents($ text_file,$ _SERVER ['PHP_SELF'],FILE_APPEND); 并且输出是: /itportal.co.il/index.php /itportal.co.il/index.php/uploads/76126568849640.png /itportal.co.il/index.php/uploads/13126494098846 .jpg /itportal.co.il/index.php/uploads/34126569172238.png /itportal.co.il/index.php/uploads/12125938246345.jpg /itportal.co.il/index.php/uploads/ 35126534663389.jpg 等。 – samoyed 2010-02-09 08:55:55

回答

0

这只是检查文件是否ex ists(作为文件-f或目录-d)。如果没有,它会将地址传递给index.php。

举例来说,如果你问:

www.mysite.com/badfile.html

您将获得:

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

这应该没有任何影响如何在index.php中运行的代码。这只影响在请求不存在的文件和目录时发生的情况。

+0

谢谢你的回答。只是要清楚 - 如果badfile.htm被请求,将index.php再次加载? - 这可以解释为什么 打印到文件的代码运行几次,而不仅仅是index.php的初始加载。 如果是这样,每次请求不存在的文件或目录时,主页将被重新加载,这对我来说至少是很奇怪的,至少是.. 这是index.php中的代码 file_put_contents($ text_file, $ _SERVER ['PHP_SELF'] ,FILE_APPEND); 和输出是: /itportal.co.il/index。php /itportal.co.il/index.php/uploads/76126568849640.png ... etc .. – samoyed 2010-02-09 08:54:56

+0

如果index.php请求badfile.html,那么是的,index.php会再次被调用。基本上,它会被index.php请求的每个不存在的文件调用。这意味着你最终可能会有一个循环,因为对index.php的新调用可能会再次请求坏文件。 – 2010-02-09 18:38:48

0

请求是在Web服务器上的文件时,拒绝访问的index.php

RewriteCond %{REQUEST_FILENAME} !-f 

请求是web服务器上的物理目录,拒绝访问的index.php

RewriteCond %{REQUEST_FILENAME} !-d 

任何除上述以外,重定向到index.php

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