index.php文件仍然需要,即使之后的.htaccess(index.php still nee

2019-10-30 11:27发布

所以我有一个服务器上的数字海洋运行。 我试图在其上运行锚CMS。 因此,这是URL应该是什么样子http://colourity.com/posts/hello-world 。 但是,这似乎并没有工作。 当我尝试http://colourity.com/index.php/posts/hello-world ,一切工作正常。 但这里的问题是,我使用.htaccess纠正这一点,这就是我有,

 Options -indexes

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule>

这应该的得到摆脱的index.php ,另外mod_rewrite启用。 我也重新启动服务器,看看是否是有差别的,但它没有。 有任何想法吗?

Answer 1:

AllowOverride All必须包含在Apache配置,这样.htaccess规则可以覆盖你的配置。 从文档:

当服务器发现一个.htaccess文件(由AccessFileName指定的),它需要知道哪些指令在文件中声明可以覆盖前面的配置指令。

当此指令设置为None,那么.htaccess文件将被完全忽略。 在这种情况下,服务器甚至不会试图在文件系统中读取.htaccess文件。

当此指令设置为All时,所有具有的.htaccess上下文的指令都允许在.htaccess文件。

它的默认值是All ,但一些模板配置文件可以有它手动设置为None 。 另外请注意,这个语法只适用于<Directory />部分。



文章来源: index.php still needed, even after .htaccess