Working on an old Drupal 5 site (I was upgrading core), I came across a very odd bug. Every time I submitted a form, I was being redirected to the frontpage of the site. I had recently installed Path Auto and Global Redirect, so I thought one of those could be causing the problem.
With Global Redirect on, when I tried to visit a normal URL with an alias, in this case, node/2
that was aliased to services
, I was also getting redirected to the home page.
I know that in the .htaccess file for the site, I had made some edits years ago when we migrated the site from flat HTML files to Drupal, so I started snooping around in there. Nothing looked too out of place, but I decided to open up a fresh copy downloaded from Drupal.org (version 5.22 as of this writing). They were just different enough, that I decided to copy over the fresh rules.
All of my redirect problems disappeared. Now we have Global Redirect and Path Auto, both of which make the site more SEO-friendly, and submitting forms does not automatically send me to the home page of the site.
When in doubt, make sure you have not hacked core.
What was wrong? If I remember correctly, the Drupal .htaccess file has some bugs with certain versions of Apache. Apache's default behavior when it causes a syntax error in a config file is to throw an error of its own, and Drupal tends to interrupt many of Apache's errors with something else. I'm guessing that somewhere in between
node/2
andservices
, Apache encountered an error, and Drupal core or Global Redirect sent us to<front>
.
Also, a bonus Drupal performance tip I located during my search to debug this problem: Move your htaccess rules into the httpd.conf file to speed up your server.