Moved Drupal 7 site to a different server, can't log in
Asked Answered
M

7

13

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.

Marcelina answered 14/11, 2011 at 17:10 Comment(6)
An explanation why the question was voted down would be appreciated.Marcelina
try asking on serverfault. stackoverflow is for programming questions. see here - stackoverflow.com/aboutTenuous
@AntonyScott So just because my question has the word "server" in it, you assume that it belongs somewhere else? This has nothing to do with the server configuration.Marcelina
hey, i didn't downvote you. someone else did. but, i have to say, I can't see the programming related problem in your question. but I'm not a drupal expert :)Tenuous
Leo ; is there a programming question here? It sounds like it's a config or server issue: everything was working before, but after a server move, it's not working.Kigali
You can improve the question by including some source code you suspect is causing the problem. However, this could be a candidate for moving to serverfault or webmaster. You say this has nothing to do with the server configuration, but you also say that this started only when you switched servers, so identifying the differences between the two servers seems like a reasonable place to start.Nevers
T
19

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';
Ticino answered 14/11, 2011 at 17:28 Comment(3)
@leo - does your site have a www. prefix, e.g. www.mydomain.co.uk ? This didn't work for me, but I have no www prefix...Exosmosis
The .mydomain.co.uk covers all domain prefixes, i.e. www or mysubdomain. It might also be worth using Drush to clear the caches if you aren't logged inTicino
I had a site on demo.domain.com/subdirectory and I had to set $cookie_domain = '.domain.com'; Thank you for the hint!Tarantass
F
17

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.

Fiberboard answered 4/9, 2012 at 8:12 Comment(3)
Solved my issue. Thanks. Just wanted to add commands for enabling Rewrite module on Apache: "sudo a2enmod rewrite" and restart apache after this command: "sudo service apache2 restart"Stagecoach
This approach really helped me solving this issue and as Qorbani commented, one can enable mod_rewrite with command a2enmod rewrite and then restart apache service.Allix
@seddonym, you saved my day. Had 'bout 10 hours now searching for that nasty problem. Had cleared caches, truncated session tables, added cookie_domain settings, removed cookies, and MUCH more. But that one did the trick. Thank you VERY much.Cardona
J
1

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

Jolandajolanta answered 14/9, 2014 at 21:57 Comment(0)
K
1

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.

Kevinkevina answered 17/11, 2014 at 1:16 Comment(0)
L
1

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)

Lamkin answered 21/11, 2014 at 11:3 Comment(0)
T
0

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

Torrent answered 11/2, 2015 at 16:43 Comment(0)
M
0

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

Motivation answered 10/1, 2018 at 14:37 Comment(2)
What do you mean not having any content? Is your file size 0 bytes?Bankrupt
The <?php print render($page['content']);?> was missing.. I saw the tabs since <?php print render($page['about']);?> was included though. Like I said, stupid.. but after two years you forget things sometimes. :pMotivation

© 2022 - 2024 — McMap. All rights reserved.