I have been given a Drupal site which I have to get it running.

I have Apache / Drupal / MySQL up and running, and created a new .conf file in Active Sites, and set the document location to /var/www/html/

I have edited my hosts file so that I have an entry for samplesite.com

If I browse to samplesite.com/index.php I see the index of the site. So far so good. It is all styled, and as I see genuine content I must be hitting the database

Now no matter what link I click on on that page, I get a 404 error. (Looking in the log files its a 404 523 error if that has any bearing on it.)

I then found out the admin userid (using drush), reset the password, and cleared all caches. Still the 404 errors.

If I go to samplesite.com/user or samplesite.com/admin, I still get the 404 error, not an admin login page.

As this is an existing site, and works online, I am blaming something in my setup / configuration (being as the url on a failed link is similar to samplesite.com/about, I am assuming it is in the navigation configuration, but now I am stuck).

Is there an apache url rewriting module (or drupal one?) that needs some configuration? Or can anyone suggest something else I may have overlooked in apache / drupal configuration?

I now have the line $base-url = 'samplesite.com'; in my settings.php file, and none of the other urls work. However it accepts that I am logged in as admin as I have an additional admin menu at the top of the page. (none of the links work though) Curiously, if I disable wifi, then the page doesn't load at all (I wouldn't have thought that wifi on or off would affect localhost)

Ok, My fix came when I followed this thread https://www.drupal.org/node/1572984

I needed to add in the following.

<Directory /var/www/html>
   RewriteEngine on
   RewriteBase /
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

However I only got here because of the help I received along the way, I think this was just the missing piece.

  • Did you try the links without the clean urls?
    – Aparna
    Commented Aug 5, 2015 at 9:08
  • No I haven't. As I can't see what the real urls are (I also see the clean urls on their live site), and can't access and of the admin areas to see what they should be. Are they stored in the database somewhere, so I can dig about and find them?
    – Matt
    Commented Aug 5, 2015 at 9:16
  • If you have admin access, try example.com?q=admin/config/search/clean-urls
    – Aparna
    Commented Aug 5, 2015 at 9:18
  • I will try that, but it won't be until later I am afraid, not in front of that machine at the moment. this wasn't a clean install of Drupal, but a copy of their live system. is there any chance that I need to edit some config files in case I am running under the wrong user (though then I'd expect a security error not a 404)
    – Matt
    Commented Aug 5, 2015 at 9:23
  • You only need to change your settings.php and then go to that link and disable clean urls for now.
    – Aparna
    Commented Aug 5, 2015 at 9:28

2 Answers 2


Option 1 - RewriteRule and RewriteBase

Check if you can use an URL containing ?q=user or ?q=admin. Refer to my answer to the question "7.26 /admin, /user not found on Localhost" (which is about RewriteRule) for more details on that.

In that answer there is a link to the question about "drupal /?q=user is working but /user not working", for which the accepted answer of that question provides more details about tuning RewriteBase in your .htaccess.

Option 2 - Admin option 'Clean URLs'

I you can use the ?q=adminURL, then try to navigate to /index.php?q=admin/config/search/clean-urls to check the current status of clean urls (if it is enabled or disabled). Make sure "clean urls" is enabled.

Refer to "Clean URL leads to duplicate URL after migration to another hosting" for more details on that.

Option 3 - base_url

Make sure the value of "base_url" is set correctly (in your settings.php).

Option 4 - .htaccess file

Verify if the .htaccess file is present in the directory where Drupal resides (and/or that it is not incomplete or corrupt). If it is missing, then upload it. If needed copy it again from the "Drupal" archive file (.zip or .tar) from Drupal.org again, and just use that new .htaccess file.

Note (about your "The ?q=admin URL didn't ask me to log in" comment to this answer) Check if you get the same problem using another browser. If with another browser it works, then that part might be a cookie problem (delete the cookie in the browser where you have the problem, and try again).

  • ?q=user will give me a login page. ?q=admin gives me a 403 I'll read the other link now
    – Matt
    Commented Aug 5, 2015 at 14:38
  • mysite.com/index.php?q=admin now takes me to an admin page, but any of the links from it go back to a 404
    – Matt
    Commented Aug 5, 2015 at 14:57
  • An incorrect RewriteBase in the main .htaccess can also cause non-front pages to break.
    – rooby
    Commented Aug 5, 2015 at 15:05
  • the ?q=admin url didn't ask me to log in, which doesnt feel right to me, but I need to be able to access everything first, before I worry about why things aren't locled down
    – Matt
    Commented Aug 5, 2015 at 15:09
  • @rooby: thanks for the "support" ... I've tried to also make that a bit more clear, via the 2nd parg I added in my "option 1" part. Would you agree that's what you also mean? Commented Aug 5, 2015 at 15:20

According to this link and my experiences I Think it is because incorrect RewriteBase in .htaccess file, one and simple solution is download raw drupal version from drupal.org (or if you has been downloaded it before) repalce .htacess file from it to your current root directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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