为什么.htaccess没有路由到我的index.php?

时间:2014-04-16 10:47:03

标签: php .htaccess mod-rewrite routes

我创建的.htaccess内容为:

Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

所以,我期待:http://mydomain.com/command/paramater1被定向到index.php,但这种情况不会发生,相反,我得到404错误。

但是,http://mydomain.com会打开index.php

我的网站目录如下:

的public_html / index.php的 的public_html / htaccess的

我启用了mod_rewrite

有什么想法吗?

修改

http://mydomain.com/command/paramater1在index.php中的url中读取命令并相应地执行操作时,我期待的是,但正如我所提到的,index.php未打开,而是404错误

1 个答案:

答案 0 :(得分:0)

<IfModule mod_rewrite.c>
    Options -MultiViews

    RewriteEngine On
    #RewriteBase /path/to/app
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

当mod_rewrite模块处于活动状态时,这会将每个页面重新路由到index.php