Answers.Body: <p>I discovered that this was caused by faulty PHP in the <code>template.php</code> file of my Drupal theme. Probably spent more than 40 hours trying to troubleshoot this, when in the end it was some custom code in my theme!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-01T15:35:40.823Z
Answers.LastActivityDate: 2015-09-01T15:35:40.823Z
Answers.UserDisplayName: LunkRat
Answers.Body: <p>When I've experienced that general issue (Drupal login redirecting to wrong the page), it's been because Apache <code>mod_rewrite</code> was disabled.</p>
  
  <p>However, some of your other symptoms are unfamiliar (eg being tied to Civi), so it may be a different issue.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T01:05:10.913Z
Answers.Text: Thanks Tim, I'm using nginx so no `mod_rewrite` here.
Answers.UserDisplayName: LunkRat
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-17T01:00:39.943Z
Answers.LastActivityDate: 2015-06-17T01:00:39.943Z
Answers.UserDisplayName: Tim Otten
Body: <p>I have one site with a very strange issue that I have been fighting for months and I'm clueless. All I know is that with CiviCRM disabled, the issue does not occur. </p>
  
  <p>When I attempt to log in and submit the login form, instead of being logged in I get redirected to some random page and 404. For example, it will say </p>
  
  <blockquote>
    <p>Page /robots.txt not found</p>
  </blockquote>
  
  <p>And I'm not logged in. The only way to log in is to disable CiviCRM via drush. Then everything works perfectly. </p>
  
  <p>It's something in the DB because I can restore this DB to a fresh <code>settings.php</code> and <code>civicrm.settings.php</code> and the error persists. </p>
  
  <p>The DB did go through an upgrade from D6 w/Civi4.5 to D7 w/Civi4.6, which is when the strange behavior started. </p>
  
  <p>Thanks for your time and insights. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-17T19:20:43.880Z
Comments.Text: Is it really random, or are there a couple of specific pages it always tries to reach? If you try restoring just civi to an empty d7 site does it still happen? Maybe we can narrow it down to civi routes vs drupal routes.
Comments.UserDisplayName: Nicholai
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-09T02:27:23.020Z
Comments.Text: Yeah, @Nicholai it actually is a handful of pages that it tries to reach. /robots.txt is one of them, and another one is some random node.
Comments.UserDisplayName: LunkRat
Tags: <drupal><upgrade>
Title: Can't log in to Drupal site: get redirected to random pages after submitting login form
ThreadText: # Can't log in to Drupal site: get redirected to random pages after submitting login form
  
  (Asked by: username_0 on 2015-06-17)
  
  I have one site with a very strange issue that I have been fighting for months and I'm clueless. All I know is that with CiviCRM disabled, the issue does not occur.
  
  When I attempt to log in and submit the login form, instead of being logged in I get redirected to some random page and 404. For example, it will say
  
  > Page /robots.txt not found
  
  And I'm not logged in. The only way to log in is to disable CiviCRM via drush. Then everything works perfectly.
  
  It's something in the DB because I can restore this DB to a fresh `settings.php` and `civicrm.settings.php` and the error persists.
  
  The DB did go through an upgrade from D6 w/Civi4.5 to D7 w/Civi4.6, which is when the strange behavior started.
  
  Thanks for your time and insights.
  
  **Tags:** drupal, upgrade
  
  > **Comments:**
  > **username_1**: Is it really random, or are there a couple of specific pages it always tries to reach? If you try restoring just civi to an empty d7 site does it still happen? Maybe we can narrow it down to civi routes vs drupal routes.  
  > **username_0**: Yeah, @username_1 it actually is a handful of pages that it tries to reach. /robots.txt is one of them, and another one is some random node.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-09-01. Score: 2 | Accepted answer
  
  I discovered that this was caused by faulty PHP in the `template.php` file of my Drupal theme. Probably spent more than 40 hours trying to troubleshoot this, when in the end it was some custom code in my theme!
  
  
  ---
  
  ### Answer by username_2 on 2015-06-17. Score: 1
  
  When I've experienced that general issue (Drupal login redirecting to wrong the page), it's been because Apache `mod_rewrite` was disabled.
  
  However, some of your other symptoms are unfamiliar (eg being tied to Civi), so it may be a different issue.
  
  > **Comments:**
  > **username_0**: Thanks Tim, I'm using nginx so no `mod_rewrite` here.  
  
  ---
  
  