Moved Drupal 7 site to a different server, can'

2019-03-25 03:58发布

问题:

I recently moved my Drupal 7 site to a new hosting server and I'm stuck at the login page. As soon as I try and log in, I get directed back to the same page, but the URL changes from /user to /user/1, which leads me to believe that I am actually logged in, but I'm not being forwarded to the correct page.

I tried cleaning my cache, emptying the cache tables in the DB but nothing helped.

Any ideas?

EDIT: To make things a bit more clear, I've used the specific server for various other Drupal 7 sites, so I know for a fact that the server configuration is not at fault here.

回答1:

I suspect your $cookie_domain in /sites/default/settings.php is incorrect.

Try making it match your new domain and ensure there's a leading dot .

$cookie_domain = '.mydomain.co.uk';


回答2:

Sometimes problems relating to logging in after a site migration can be because mod_rewrite was enabled on the first machine but not the second. A simple way to test this is to use the ?q= URL format (http://site.localhost?q=user) and see if you can log in like that. If that works then you can either disable clean urls from within the Drupal interface, or enable mod rewrite in Apache.



回答3:

In my case the issue was solved only after refreshing .htaccess file in drupal root folder. You can take the source here: https://github.com/drupal/drupal/blob/7.x/.htaccess



回答4:

seddonym's comment about mod_rewrite led me to a slightly different solution. I was having the same problem but was able to solve it by copying the file rewrite.load from /etc/apache2/mods-available to /etc/apache2/mods-enabled.

I think the files in mods-enabled are some sort of link files (I am novice at linux still) but copying the files worked just fine. Maybe someone will come along and tell us the proper way to do this.



回答5:

Sometimes all you need is to clear the cookies for the domain/website - it's possible you have old cookies alive that are causing this.

Get a cookie manager to help simplify this, e.g.:

Edit This Cookie (for Chrome)



回答6:

Other answer might be that rewrite php module is not installed, to do that do the followings:

sudo a2enmod rewrite

Restart apache2

sudo service apache2 restart



回答7:

In my case it was very stupid, on my page.tpl.php, there wasn't any "content" and the page--user.tpl.php didn't get read. Only had the line to show content in the page.tpl.php

Although that it is unlikely that you're as stupid as me. ;) Maybe it will be helpful anyway.

Arne