When I visit localhost the site does not work. It shows some text from the site but it seems the server can not locate any other files. Here is a snippet of the errors from firebug:

"NetworkError: 404 Not Found - localhost/css/popup.css"
"NetworkError: 404 Not Found - localhost/css/style.css"
"NetworkError: 404 Not Found - localhost/css/player.css"
"NetworkError: 404 Not Found - localhost/css/ui-lightness/jquery-ui-1.8.11.custom.css"
"NetworkError: 404 Not Found - localhost/js/jquery.js"

It seems my server is looking for the files in the wrong places. For example, localhost/css/popup.css is actually located at localhost/app/webroot/css/popup.css.

I have my site setup on a remote server with the same exact configurations and it works perfectly fine. I am just having this issue trying to run the site on my laptop at localhost. I edited my VirtualHosts file DocumentRoot and to /home/user/public_html/site.com/public/app/webroot/ and this reduces some errors but I feel that this is wrong and sort of hacking it since I didn't use these setting on my production server which works.

The last note I want to make is that the website uses dynamic URLs. I dont know if that has anything to do with it. For example, on the production server the URLS are: site.com/#hello/12321.


I have a LAMP server setup on my laptop which runs on Ubuntu 11.10.

I have enabled mod_rewrite:

sudo a2enmod rewrite

Then I edited my Virtual Hosts file:

<VirtualHost *:80>
  ServerName  localhost
  DirectoryIndex index.php
  DocumentRoot /home/user/public_html/site.com/public

    <Directory /home/user/public_html/site.com/public/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all

Then I restarted apache. My website is using cakePHP. This is the directory structure of the website: "/home/user/public_html/site.com/public" contains:

index.php app cake plugins vendors

These are my .htaccess files:


<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]


<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

4 Answers 4


You have .htaccess in your app/ and app/webroot dirs, but nothing in your root directory.

You should have the file: /home/user/public_html/site.com/public/.htaccess

RewriteRule    ^$    app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1    [L]


Change your docroot to

DocumentRoot /home/user/public_html/site.com/public/app/

Both of these answers are assuming public/index.php isn't running some sort of advanced routing on the URI. Having nested .htaccess files doing rewrites is messy though.


Your site is under /home/user/public_html/site.com/public.

It contains: index.php app cake plugins vendors

And your root .htaccess file is:

RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]

So this means: whatever it is, go to the webroot folder in your installation.

But I don't see any webroot folder. Am I missing something?

  • My webroot folder is located: /home/user/public_html/site.com/public/app/webroot/. It contains "css css.php favicon.ico files img index.php js template". Thanks for your reply. Jan 1, 2012 at 18:58

I see no mention of logs. Firebug is not Apache error logs. There is no substitute for the Apache error logs in this case, so crank up error logging and check error.log



On your laptop, do you have AllowOverride set in your apache config somehwere to allow the use of .htaccess files?

See: http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

For details.

Or just add the following to your httpd.conf and restart apache:

AllowOverride All

If that helps, then check out the above link and refine the AllowOverride directive. If it does not help, then take out the AllowOverride you added (but leave in any onthers that were already there) and restart apache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.