I restored my Drupal 7 site from backup and now can't get to the admin page.

Getting a Drupal 404 page on example.com/index.php?q=admin as well as example.com/?q=admin.

Needless to say admin/ also gives a 404.

Same file system and database were working yesterday.

  • Is the .htaccess file intact in the webroot? – Kevin Nov 18 '17 at 2:07
  • oh yes. I'm fairly sure it's the default. That wouldn't have an effect on running ?q=admin would it? – MikeiLL Nov 18 '17 at 3:29
  • Did you make any changes for server configuration? If no then just replace the .htaccess file from fresh drupal installation files. – Prem Patel Nov 18 '17 at 5:55
  • I can get to example.com/user and log in which seems to do the trick. Very new to Drupal. Is this normal? – MikeiLL Nov 19 '17 at 5:34
  • Are you sure it was a 404 and not 403? – Akko Nov 20 '17 at 9:02

The answer appears to be that the /admin or ?q=admin path only exists when you are logged in to Drupal as an administrator.

The login page is reached at example.com/user/login.

| improve this answer | |
  • This isn't really an answer, it could be a permission issue, bad code in a custom module, busted database table, etc. The path always exists, you proved that it does, but other users not being able to access it sounds like a permission issue. – Kevin Nov 26 '17 at 20:03
  • Do you mean that example.com/admin should be bringing up a login page? – MikeiLL Nov 26 '17 at 20:15
  • It should say access denied if you are not logged in, or are logged in and your role does not have permission to access administrative pages or something of that nature. It will only bring up a login page IF you are not logged in if you installed something like LoginToboggan or one of those contrib modules that puts login forms on 403 responses. – Kevin Nov 26 '17 at 20:21
  • Might there be a 403 page in the theme that might be missing or have bad permissions or something, since the 404 page that's getting served is a Drupal one? – MikeiLL Nov 27 '17 at 0:20
  • 403/404 pages are served directly from Drupal unless you override them with a node. Getting a 403 on /admin doesn't change the underlying cause. – Kevin Nov 27 '17 at 0:29

I encountered this problem on a localhost install of Drupal 8 on Ubuntu18.04. I could see the base url page but every link into my site was 404 (e.g. any link from the admin bar).

Clean URLs

I started with the Drupal.org page, "Page Not Found" Errors on every page except homepage where I found this:

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.

Then I found a solution which translated this for me into practical steps. I enabled "Clean URLS", following a hint on Install Drupal on Ubuntu 18.04 Bionic Beaver Linux.

  1. edit Apache's default site configuration /etc/apache2/sites-enabled/000-default.conf

    $ sudo vim /etc/apache2/sites-enabled/000-default.conf
  2. insert the following just after the line that has DocumentRoot /var/www/html

    <Directory /var/www/html/>
               Options Indexes FollowSymLinks
               AllowOverride All
  3. restart Apache

    $ sudo systemctl restart apache2
| improve this answer | |

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.