I recently migrated a drupal site onto a new server, with a new domain name (modernist-magazines.org), and can only view the home page. Any time I attempt to log in or click through to view some content, I get a 404 error, i.e.:

Not Found

The requested URL /content/new-ages-foreign-affairs-and-sinking-lusitania was not found on this server.
Apache/2.2.3 (CentOS) Server at www.modernist-magazines.org Port 80

After installing mysql and php on the server, here's how I set up the drupal site.

On the old server:
1. Took a mysql dump of the database as a .sql file.
2. Created a tar archive of the drupal files.

On the new server:
3. Created a new database and imported the .sql file.
4. Untarred the files archive into the drupal root, making sure to copy over the .htaccess file.

This seems suspiciously like a .htaccess issue to me, but I can't quite figure it out. I have pasted the content of my .htaccess below.

I also took a SQL dump of the new database and looked at it in a text editor, because I thought there might be some links pointing to the old server, but there aren't any.

Any suggestions would be much appreciated.

Thanks,

Jeff

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch
"\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-$
 Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
 # There is no end quote below, for compatibility with Apache 1.3.
 ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
 php_value magic_quotes_gpc                0
 php_value register_globals                0
 php_value session.auto_start              0
 php_value mbstring.http_input             pass
 php_value mbstring.http_output            pass
 php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
 php_value magic_quotes_gpc                0
 php_value register_globals                0
 php_value session.auto_start              0
 php_value mbstring.http_input             pass
 php_value mbstring.http_output            pass
 php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
 php_value magic_quotes_gpc                0
 php_value register_globals                0
 php_value session.auto_start              0
 php_value mbstring.http_input             pass
 php_value mbstring.http_output            pass
 php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
 # Enable expirations.
 ExpiresActive On

 # Cache all files for 2 weeks after access (A).
 ExpiresDefault A1209600

 # Do not cache dynamically generated pages.
 ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
 RewriteEngine on

 # If your site can be accessed both with and without the 'www.' prefix,
you
 # can use one of the following settings to redirect users to your
preferred
 # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one
option:
 #
 # To redirect all users to access the site WITH the 'www.' prefix,
 # (http://example.com/... will be redirected to
http://www.example.com/...)
 # adapt and uncomment the following:
 # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
 # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
 #
 # To redirect all users to access the site WITHOUT the 'www.' prefix,
 # (http://www.example.com/... will be redirected to
http://example.com/...)
 # uncomment and adapt the following:
 # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
 # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

 # 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 site is running in a VirtualDocumentRoot at
http://example.com/,
 # uncomment the following line:
 # RewriteBase /

 # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_URI} !=/favicon.ico
 RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

Comments

ionut.alexuc’s picture

Can you try to use the non clean urls?

Try, http://www.your-site.com/?q=user/login

If that works, then you have issues with .htaccess
Even if you have that drupal standard .htaccess, are you sure your hosting use it?

jdrouin’s picture

Yes, I've tried that. If I go to mysite.org/?q=user/login, I can see the log in page just fine. I first entered an incorrect username (typo) and it gave me the error message that there was a mismatched username and password. Then I entered the correct ones and got the same Not Found error as listed above.

Maybe it's a file/folder ownership or permissions issue?

stickyBandit’s picture

Hello,
I had this same problem, I migrated my server, tried to update the php file, which caused apache to not start. Then, after re-installing everything, I got it up to show the front page of my drupal install, but every link that I would click on the site, would just bring me to the front page.

It turned out to be enabling in Apache the mod_rewrite in httpd.conf .

More details can be found on http://drupal.org/node/404018

Good luck!

anewbie’s picture

It works. Amazing !!! Thanks a lot.

Crom’s picture

Hopefully this will help someone else:

If you've used scp to migrate site files between servers using the -r switch (recursive copy) then the copy process misses out the .htaccess file in the drupal root directory (but does copy the others eg in files directory). Had me scratching my head for a bit!

Cheers,
Crom

cblanglois’s picture

Hi, sorry I'm not a programmer, so can you please tell me exactly where I can find the httpd.conf?
I know you're saying it's in Apache, but where can I find all these files in my Apache server? How do I access it?

My servers are on Godaddy, in case that info helps.

Thanks a lot! Would certainly appreciate a reply.

cblanglois’s picture

Turns out I can't access my apache because it's a shared server, not a dedicated server.

So how do I solve the problem without having to access apache?

Please help. :(

alienzed’s picture

Uncommenting the following line might help as well.

# RewriteBase /

JohnnyW’s picture

Had to comment out RewriteBase /

in .htaccess file when I took files from server, that is using virutalhost file to WAMP

so just edit RewriteBase / to # RewriteBase / in .htaccess for WAMP to work.

vmevada102’s picture

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
  # There is no end quote below, for compatibility with Apache 1.3.
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_value mbstring.encoding_translation   0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

  # 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 /gardi
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /gardi

  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>