Using .htaccess to redirect underscores to dashes

The following tutorial explains how to use .htaccess to redirect underscores _ in a tag url to dashes -. This is very important for Search Engine Optimization (SEO) because many search engines including Google do not recognize underscores as spaces between words. They do however, recognize dashes to separate words and tag keyword phrases.

Redirect underscores to dashes using .htaccess:

  1. Login via ftp to your sites root directory
  2. Locate and copy your .htaccess file to your desktop
  3. Using a text editor, add the following lines (replacing yoursite with your actual sitename) to the top of your .htaccess file and save the file:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^tag/(.*)_(.*)$$1-$2 [R=301,L]
    RewriteRule ^tag/(.*)_(.*)$$1-$2 [R=301,L]

  4. Upload the new .htaccess file to your sites root directory and enjoy