Redirects from www content to www2

Overview

As sites are published in the Drupal WebCMS, OEI will redirect our www.epa.gov/xxxx aliases and pages to the new Drupal WebCMS content.  OEI requests the top level aliases from the server administrators.  The default is to create a redirect that points all content to the new homepage.  If you want to create page to page redirects you have to do that yourself in your TSSMS area.  The top level redirect, still requested by OEI, has to be set differently with only the http://www.epa.gov/alias to go to new web area homepage.  You have to publish the Drupal WebCMS content before the redirect can be requested.

This page explains how to create a .htaccess file to redirect content from your TSSMS account to pages within the Drupal environment.  You should use explicit 301 redirects as shown in the examples.

Tip:  If you had a top level alias to a subdirectory, you need to keep the subdirectory for the alias to continue to work.  When you delete your outdated and superceded content from your old TSSMS area,  do not delete the directory that the content was in.  

Tip 2:  Coordinate with OEI ahead of time so that we're aware that we'll need to request a redirect.

Instructions

1. Create an empty text file using a text editor such as notepad, and save it as htaccess.txt.
NOTE: The reason you should save the file as htaccess.txt is because many operating systems and FTP applications are unable to read or view .htaccess files by default. Once uploaded to the server you can rename the file to .htaccess.

2. Edit the contents of the file. Check the following examples:

301 (Permanent) Redirects should be used to redirect a single page on the TSSMS account to its corresponding Drupal WebCMS page. 

This example shows the format for redirecting a single URL to another single URL.

Redirect 301 /nandppolicy/links.html http://www2.epa.gov/nutrient-policy-data/additional-resources

More powerful URL changes with mod_rewrite

Redirect all files in a directory except for one page to a Drupal WebCMS page:
Redirect 301 /nandppolicy/links.html http://www2.epa.gov/nutrient-policy-data/additional-resources
RedirectMatch 301 /nandppolicy/(?!links.html) http://www2.epa.gov/nutrient-policy-data

Note: ?! in this example means exclude the links.html file. The first line takes users who visit the links.html page to its replacement page in Drupal. The second line redirects everything else except for links.html to the web area homepage.

Exclude multiple folders within a subdirectory while redirecting all files in the parent subdirectory:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/tri/tridata/data
RewriteCond %{REQUEST_URI} !^/tri/tridata/tri11/nationalanalysis
RewriteRule ^tridata/(.*) http://www2.epa.gov/tri/tri-data-and-tools [R=301,L]

Redirect all files under a folder:
RedirectMatch 301 /region8/superfund/co/(.*) http://www2.epa.gov/region8/colorado-cleanup-sites
RedirectMatch 301 /region8/superfund/nd/(.*) http://www2.epa.gov/region8/north-dakota-cleanup-sites

3. Upload this file and re-name it to .htaccess.
NOTE: If using a text editor, be sure to save the file as plain text.