2

I can't seem to get URL rewriting to work on a Ubuntu 12.04 server with apache2 and when the default page loads (home) it's just plain text without CSS . I'm using Cake 2.3.9 and I get the following message upon a fresh install to /var/www/. So my root directory looks like

/var/www/app
/var/www/lib
/var/www/index.php
/var/www/.htaccess
....

The error I get is

URL rewriting is not properly configured on your server. 1. Help me configure it 2. I don't / can't use URL rewriting

I tried everything in this post but I stil get the message.

The only thing from that post I didn't do is the accepted answer, which was

Turns out the .htaccess file was not getting copied alongside the cakePHP source. This is a common issue when using the cp command or not having hidden files visible in a file browser, unless you copy the top-level directory. Doing a direct copy of the file to my project folder fixed it for me without having to mess with my apache settings.

Is that user suggesting to make sure .htaccess is /var/www? I don't quite get what they're suggesting to do. I downloaded Cake locally and then used SFTP to upload it to /var/www on my ubuntu server.

Unless there is some alternate modrewrite setting, I'm almost positive it's enabled. When I type sudo a2enmod rewrite it says Module rewrite already enabled

I've also tried everything here and still no luck. I'm completely stuck.

Community
  • 1
  • 1
user1443519
  • 591
  • 1
  • 12
  • 26

2 Answers2

0

Yes, .htaccess will need to be in the public web root directory - /var/www in this case. Make sure the file is readable by your web server, too.

If this doesn't work: Make sure that the mod_rewrite module is installed and enabled. It should be on Ubuntu 12.04. You can check by listing the contents of /etc/apache2/mods-enabled. You should see rewrite.load listed.

If not, you can enable it as so:

sudo -i
cd /etc/apache2/mods-enabled
ln -s ../sites-available/rewrite.load rewrite.load
apache2ctl restart
Panoctopus
  • 41
  • 3
  • I'm using apache2 so I did cd /etc/apache2/mods-enabled. When I tried to make the link it responds with "ln: failed to create symbolic link `rewrite.load': File exists" – user1443519 Nov 30 '13 at 23:05
  • Yes, apache2 - will edit the answer. Looks like it's already there, then. Should show the simlink when doing an LS. – Panoctopus Nov 30 '13 at 23:10
  • I tried your edited answer and it still gives the message "ln: failed to create symbolic link `rewrite.load': File exists" – user1443519 Nov 30 '13 at 23:12
  • Sorry - I mean that you don't need to create the link, as the file exists - so this enabled (looks like you've the same answer from a2enmod). – Panoctopus Nov 30 '13 at 23:15
0

I uninstalled and reinstalled my LAMP stack and it now works. I also downgraded to CakePHP 2.3.8 from 2.3.9, so maybe there was something in there too.

Regardless, it's now working!

user1443519
  • 591
  • 1
  • 12
  • 26