1

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:

Community
  • 1
  • 1
CodingBeagle
  • 1,888
  • 2
  • 24
  • 52
  • 1
    Can you check if htaccess is actually being processed? – hjpotter92 Sep 27 '15 at 18:43
  • Hey @hjpotter92 ! :) Sorry about the silly question, but I'm quite new to web dev and server usage in general. How can I check if htaccess is being processed? :) – CodingBeagle Sep 27 '15 at 18:46
  • Put a general rewrite to redirect you to some other page: `RewriteRule ^ http://google.com [R,L]`. It should be above all other rules, just after `RewriteEngine On` directive. – hjpotter92 Sep 27 '15 at 18:48
  • @hjpotter92 , Interesting. I put the line in (you can see my edit in the original post for the current look of the .htaccess file), and it seems like no redirect takes place. Perhaps it is not being executed after all. – CodingBeagle Sep 27 '15 at 18:54

1 Answers1

2

It appears that the mod-rewrite is not being loaded.

See your server configuration file (httpd.conf). There should be a statement as follows:

LoadModule rewrite_module modules/mod_rewrite.so

If the line starts with #, remove the # character. You can also use the command:

a2enmod rewrite

Also, try to shift your Rewrites outside of the IfModule block.

Options -indexes

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]
hjpotter92
  • 78,589
  • 36
  • 144
  • 183
  • That was spot on! :) Indeed, mod-rewrite was not being loaded! I already have a website up on the server that uses mod-rewrite, however I noticed that the LoadModule line appears in that website's own VirtualHost directive! I hadn't applied it globally. Doh! Doing that and restarting the apache server did the trick :) Thank you very much! – CodingBeagle Sep 27 '15 at 19:18