Category Archives: anchor-cms

Can’t get Anchor CMS rewriting to work

I'm currently attempting to install Anchor CMS on my Apache server.

I have successfully deployed it to the server. That is, when I go to www.domain.com, I am greeted with the default-themed front page and a test post :)

However, if I try to click the post, or go to the admin area, I get an error such as:

Not Found: The requested URL /posts/hello-world was not found on this server.

However, if I follow the (in this case) post link using a direct link, such as:

www.domain.com/index.php/posts/hello-world

It works completely fine. So, it appears to be a problem with the rewriting.

I found another problem on Stackoverflow exactly like mine, located here

Unfortunately, I did the same steps and nothing works. Just to recap, this is how my VirtualHost looks:

<VirtualHost *:80>
    ServerName www.domain.com
    ServerAlias domain.com
    DocumentRoot /var/www/domain.com/public_html

    <Directory /var/www/domain.com/public_html>
        AllowOverride All
        Require all granted
    </Dictory>
</VirtualHost>

And this is how my Anchor CMS config.app file looks:

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

    ...(rest of the data here)...

As the documentation states to use an empty index in this default case.

My .htaccess currently looks like this:

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/$1 [L]
</IfModule>

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

And it is located in the document root "public_html"

Sadly, even with these things configured, I still get the "Not Found" errors. I don't really know where to go from here :(

EDIT

Options -indexes

<IfModule mod_rewrite.c>
        RewriteEngine On

        RewriteRule ^ http://google.com [R,L]

        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/$1 [L]
</IfModule>

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

I tried to put in a general rewrite to the .htaccess file, and it seems like it's not being executed: