University of Oregon

Redirect an entire Drupal site – .htaccess

I’ve migrated several Drupal sites to new servers lately and since some of those sites were in development they didn’t have a proper cName. So I’ve been using a .htaccess redirect to channel all traffic from the old site to the new ones.
Here’s an example of the new .htaccess file I placed in the /hr_diac directory on my old server:
##Redirect everything that pointed to /hr_diac to http://access-guide.hrstg.uoregon.edu/$1

RewriteEngine on
RewriteCond %{REQUEST_URI} /hr_diac [nc]
RewriteRule ^(.*)$ http://access-guide.hrstg.uoregon.edu/$1 [r=301,nc]

To clarify; I completely replaced the drupal .htaccess file with this file.
It’s pretty simple but it works.

Handle sites/default/files redirect in Drupal 6 with Custom Errors module

When I’ve migrated sites into Aegir recently, I find that the users have many links in the content hard-coded to files in the default directory.
While it is possible to use the Scanner search & replace module to ferret those out. It’s not always thorough enough. For example, it doesn’t search and replace menu link urls, or content in blocks, views, headers, footers or custom fields. You can specify custom fields and locations to search but that’s another bag of worms that fraught with issues.
So I wanted to find a simple way to catch any hard coded links that I missed.
Enter the Custom Error module.

I’ve been using it to provide a populated search form on the 404 ‘Not found’ page as well as a site map but I also have a few custom redirects in there so adding an option for sites/default/files was simple.

Here’s the code: (more…)