【发布时间】:2012-01-11 17:05:12
【问题描述】:
我目前的 htaccess 文件包含执行此操作的 mod_rewrite 规则:
www.mysite.com/articles/jkr/harrypotter --> www.mysite.com/index.php?p=articles&author=jkr&book=harrypotter
www.mysite.com/articles/jkr --> www.mysite.com/index.php?p=articles&author=jkr
www.mysite.com/articles --> www.mysite.com/index.php?p=articles
在我的根目录中,我有一些 PHP 文件,例如:index.php、pre.php、view.php 等。
我想要的:阻止直接访问 php 文件。
例如:
www.mysite.com/index.php --> "404 - Page Not Found" or "File not exist"
www.mysite.com/view.php --> "404 - Page Not Found" or "File not exist"
我尝试了在搜索时找到的代码。它使用“f”标志。但我不明白。当我使用它时,它也不显示主页。所以,我删除了我正在测试的所有内容。我的 htaccess 文件现在只包含三个规则(接受页面、作者、书籍)。
请帮忙。
【问题讨论】:
-
抱歉,我找到了解决方案:stackoverflow.com/questions/1055652/…
标签: php mod-rewrite