apache icon
14th
Apr 10

Redirect Old Domain Names with Apache htaccess File

Posted Wednesday 14th April 2010
Redirecting an old domain name to a new domain name is typically very easy with Apache. This is probably the easiest and most compatible way to create redirects with Apache that doesn’t use the Apache rewrite module (mod_rewrite).

Redirect an identical site to a new domain
If the website is the same, just under another domain, you will want to redirect everything (by using a /). In the example below the URL “http://www.oldsite.com/about.php” would redirect to “http://www.newsite.com/about.php”:

1
Redirect 301 / http://www.newsite.com/

Redirect pages to a new website
If you have created a completely new website on another domain (that has different URLs and file names) you will most likely have to manually redirect certain pages. In that case you would use:

1
Redirect 301 /theoldpage.html http://www.newsite.com/newpage.php

Redirect everything to a new domain (specific page)
If you have a completely new website that has different filename and page locations you might want to redirect everything on your old domain to an absolute URL. To do this you use the asterisk (*) instead of the root forward slash (/).

1
Redirect 301 * http://www.newsite.com/

For more complex rewrites you will most likely need to look into using mod_rewrite (the rewrite module for Apache servers). You can also rewrite URLs with PHP (although I don’t recommend it).

Bookmark or share this page:

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

Related posts:

  1. Mapping Linux (ext3) File System for use in Apache under Windows
  2. URI Rewriting Alongside WordPress’ PermaLinks
  3. PHP URL Rewriting Without Apache and mod_rewrite


MSN Contact: contact [at] danielgibbs.net



No Comments

No comments yet.

TrackBack URL

Leave a comment