tahquitz
By:
tahquitz

cakePHP URL rewriting not working in Ubuntu

March 15, 2015 2.2k views
PHP Frameworks Configuration Management Ubuntu

I recently installed a new droplet and followed the tutorial on the site for the installation of cakePHP on Ubuntu. I have confirmed that i have the url rewrite module in apache2 enabled (shows as shared in terminal), but when I go to my site I get a warning that URL rewriting is not properly configured. Any help would be appreciated.

3 comments
  • In addition to enabling the rewrite module have you ensured that your root directory is set to AllowOverride All instead of the default AllowOverride None in your virutalhost configuration in /etc/apache2/sites-enabled/

    This setting allows configuration in an .htaccess file to override the configuration files and do things like url rewrites. Once you have changed the configuration file be sure to restart Apache with:

    service apache2 restart
    
  • Maybe I'm missing something, but the only file in that directory is 000-default.conf and the file is empty. Admittedly I am new to this and may just be missing something.

  • What did the trick for me was modifying the /etc/apache2/apache2.conf
    Change:

    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
    </Directory>
    

    To:

    <Directory /var/www/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
    

    Reload apache after you modify it.

1 Answer

This question was answered by @lancasterjones:

What did the trick for me was modifying the /etc/apache2/apache2.conf
Change:

<Directory /var/www/>
       Options Indexes FollowSymLinks
       AllowOverride None
       Require all granted
</Directory>

To:

<Directory /var/www/>
       Options Indexes FollowSymLinks
       AllowOverride All
       Require all granted
</Directory>

Reload apache after you modify it.

View the original comment

Have another answer? Share your knowledge.