如果文件不存在,htaccess重定向将不起作用

时间:2011-01-20 11:23:39

标签: apache .htaccess apache2 debian

服务器:Debian with apache2;

无功/网络: 项目 - > /桑巴/项目/

桑巴/项目: 的index.php 的.htaccess test.php的

htaccess的:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /project/

RewriteCond %{REQUEST_URI} !index.php.*
RewriteRule ^(.*)$ index.php [L]

localhost / - >它的工作原理

localhost / index.php - >它的工作原理

localhost / test.php - >它工作(重定向到index.php工作)

http://localhost/asdsads - >不起作用(错误403)

为什么?

THX

1 个答案:

答案 0 :(得分:3)

尝试将最后两行更改为

RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^ index.php [L]

第一行检查请求的URL是否未映射到物理文件,第二行检查每个请求(总是有一个开头,用^表示)到index.php。