如何在 apache 上为锚 cms 重写指令

How to rewrite directive on apache for anchor cms

我正在使用一个名为 anchor 的 cms。 http://anchorcms.com/docs/getting-started/configuration

当我进入域时。com/posts 我得到一个 404,

当我进入域时。com/index。php/posts 页面显示正确。

这是我的 httpd.conf 文件

<VirtualHost *:443>
#ssl blah blah

DocumentRoot /var/www/anchor/
ServerName domain.com
ServerAlias domain.com

<Directory /var/www/anchor/anchor/>
    AllowOverride All
    Options Includes MultiViews
    Require all granted
</Directory>

</VirtualHost>

这是我放在 /var/www/anchor/

中的 .htaccess 文件
Options -indexes

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /

        # Allow any files or directories that exist to be displayed directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d

        # Rewrite all other URLs to index.php/URL
        RewriteRule ^(.*)$ index.php/ [L]
</IfModule>

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

我对如何配置这个 cms 感到有点困惑,.htcaccess 应该放在 "document root" 中,我很确定我把它放在了正确的文件夹中。我认为我不必将 url 设置为子目录。有什么建议吗?

这是我的配置文件。 /var/www/anchor/anchor/config/app.php

<?php

return array(
        'url' => '/',
        'index' => '',

您的文档根目录是 /var/www/anchor,但您只允许覆盖 /var/www/anchor/anchor。如果您不是全局允许覆盖,那将禁用您的 htaccess 文件。尝试更改您的 <Directory> 标签以匹配文档根目录:

<Directory /var/www/anchor>
    AllowOverride All
    Options Includes MultiViews
    Require all granted
</Directory>