由于配置错误,无法访问root-dir

时间:2016-06-25 11:11:46

标签: .htaccess mod-rewrite url-rewriting

我有一个重写规则:

RewriteRule ^((?!index\.php)[^/]+)/?$ index.php?page=$1 [L]

example.com/index.php?page=something重写为example.com/something

此重写规则不允许我进入example.com/(some-file-here),例如:

example.com/favicon.ico
example.com/robots.txt

要显示图标,我只需将其放入/images/favicon.ico之类的内容,但我更喜欢正确配置的.htaccess并将favicon.icorobots.txt放入根目录中DIR。

我必须在此规则中进行哪些更改才能访问example.com/(some-file-here)

1 个答案:

答案 0 :(得分:1)

您需要从规则中排除真实文件和文件夹,请尝试:

RewriteEngine on

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