Community Documentation

"Page Not Found" Errors on every page except homepage.

Last updated June 1, 2010. Created by criznach on February 29, 2008.
Edited by mr.baileys. Log in to edit this page.

Narrow the problem

The most likely cause is misconfiguration of mod_rewrite or clean URLs on the new server. Confirm this by short-circuiting the clean URL system and requesting pages directly, like this:

http://www.example.com/index.php?q=user

If the login page is shown, then you can assume that Drupal's page serving mechanism is working properly, but mod_rewrite isn't working. To determine if mod_rewrite is enabled, create a file called phpinfo.php in the root of your site. This file should be accessible from a web browser and contain this code:

<?php
phpinfo
();
?>

Ensure that mod_rewrite is enabled

Navigate to phpinfo.php in a browser like this: http://www.example.com/phpinfo.php

On that page, look for a section called "Loaded Modules" and check that mod_rewrite is included. If not, mod_rewrite is not being loaded by apache and will need to be enabled. The process will be different depending on the server platform and apache build. Keep the phpinfo.php file for now - it will be helpful later.

Ensure that Drupal's .htaccess file is being used

Once it's been confirmed that mod_rewrite is enabled, double check that Drupal's .htaccess file is in the site's root, and that it is working. Confirm that .htaccess is enabled by temporarily replacing Drupal's .htaccess file. Make a backup of the existing .htaccess and create one like this...

DirectoryIndex phpinfo.php

Now try the site URL without specifing a page or file in a web browser: http://www.example.com/. If you see PHP's phpinfo dump, the .htaccess file worked and you can restore the old one. If not, the server may not be allowing .htaccess overrides for your site.

Double check your rewrite_base setting

If phpinfo was displayed, something may be misconfigured in the existing Drupal .htaccess file. Check the documentation for "RewriteBase" and "RewriteEngine" settings.

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Enable necessary .htaccess overrides

If phpinfo was not displayed, locate your apache configuration file and enable the necessary .htaccess overrides. This location will vary by server platform, so check the appropriate documentation. In this example (Ubuntu server), the default apache vhost configuration was located at:

/etc/apache2/sites-enabled/000-default

To configure mod_rewrite from .htaccess, the apache config needs to allow at minimum "FileInfo" overrides. In order to make the simple DirectoryIndex test work, apache needs to allow "Index" overrides. Locate the section in the apache configuration file or included vhost configuration file that looks like this:

<Directory /filesystem/path/to/your/sites/root>
</Directory>

Within that block, either add or edit the apache AllowOverride directive. This can create security risks, so see the official reference here:

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

To allow all overrides, it will look like this:

<Directory /filesystem/path/to/your/sites/root>
  AllowOverride All
</Directory>

To only allow selected overrides, specify them individually like this:

<Directory /filesystem/path/to/your/sites/root>
  AllowOverride Indexes Options FileInfo
</Directory>

Now reload the apache configuration. This is also different by platform, so consult the appropriate documentation. On Ubuntu server the command is:

# /etc/init.d/apache2 reload

Navigate a browser to http://www.example.com/ and PHP's phpinfo should be displayed. If so, replace it with Drupal's .htaccess file and your site should now be working as expected.

If clean URLs are still not working, go back to the section titled Double check your rewrite_base setting.

Comments

Temporary URL Issues

If you are using a temporary URL such as 192.168.0.42/~username because the domain has not been transferred yet or has not propagated yet, you would have the problem described above until the domain name is transferred over.

To be able to use Drupal before the domain name points over, you will need to change something in the .htaccess file:

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal

If your temporary URL is something like 192.168.0.42/~username then you will need to add the following line in .htaccess:

RewriteBase /~username

Once you point the domain name over to the website, be sure to comment out or delete that line.

Hope that helps.

--
Scott M. Stolz
http://www.wistex.com/
http://www.cardservicenet.com/

--
Scott M. Stolz
http://www.wistex.com/

Page not found after update from 6.10 to 6.12

After updating from 6.10 to 6.12, all my pages return a 'page not found' error, except my admin and front-end homepage.
I spent many hours figuring out what caused this, but at the end, it was a silly mistake I made myself (as usual).

I did not backup the .htaccess file since I though I had not changed this, but of course I had to comment out the 'Options -Indexes' and 'Options +FollowSymLinks'.

Hope this is helpful for anybody who might be as stupid as me.

Don't try.

I had this problem and both

I had this problem and both checks passed.

1. Ensure that mod_rewrite is enabled
2. Ensure that Drupal's .htaccess file is being used

The way I solved the problem was to add the following to my httpd.conf and restarted apache.

<Directory /filesystem/path/to/your/sites/root>
  AllowOverride All
</Directory>

restart apache
/etc/init.d/httpd restart

Fixed by adding

ServerName localhost

to httpd.conf -- with this plus your suggestion, plus the tips above, everything works.

Acquia Dev Desktop

I was trying to devel locally using Acquia Dev Desktop from an existing site hosted by Acquia. I ran into this problem and like jawbreak, both tests passed.

I tried jawbreak's solution along with one after with no luck.

Finally, I decided to comment out extra config settings I had in my settings.php (for some reason, when I import the codebase into Acquia Dev Desktop, it automatically creates another folder under docroot/sites/ called whatever you named your local site name. Inside that folder contains another settings.php and another files folder).

I edited both docroot/sites/default/settings.php and docroot/sites/[localsitename]/settings.php and by chance, I commented out ALL my fast_404 configs. Immediately, that brought back all the pages to the site, after hundreds of tries to edit the httpd.conf files and .htaccess files.

I also simplified the file by commenting out other extra configs like memcache, and reverseproxy stuff.

Oh, one more thing, in case anyone else did the same thing I did, when downloading the codebase from Acquia, I chmod all directories to 755 and files to 644, at least that's what I have on my local trunk...it was too locked down for Dev Desktop.

I hope that helped somebody.

shared hosting. my hosting

shared hosting. my hosting provider dont want to enable mod_rewrite. any solution to this?

belajar drupal, makan drupal, tidur drupal

i get the solution at 3 am.

i get the solution at 3 am. just disable clear URL. its bad for SEO but thats the only way.

belajar drupal, makan drupal, tidur drupal

THANKS

Great post!
I installed Ubuntu in my system and found that the backup of a Drupal website is not working. I could only see view the site's home page and every page that I tried to access even the /user page gave "Page not found" error.

Spent hours to figure out the problem and found this article's next page, but couldn't found the appropriate answer.. until I saw this post.
Just a simple change in AllowOverride and my site is working again.

Thank you very much :)

Regards,
Subhojit Paul
Web Developer @ Innoraft Solutions

About this page

Drupal version
Drupal 4.7.x, Drupal 5.x, Drupal 6.x, Drupal 7.x

Reference

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.