Forum Moderators: phranque
See Apache mod_alias [httpd.apache.org] and mod_rewrite [httpd.apache.org], or search WebmasterWorld for examples [google.com] to get you started.
Jim
The redirect code goes in a file, usally called ".htaccess" (maybe just "htaccess" on windows machines) in any directory on your site. It's scope is determined by which directory you put it in. If you put it in your Web root directory (where your "home page" is, then it can affect all requests all requests to your site. If you put it in a subdirectory, it can affect only requests to that subdirectory and its children.
A simple 301 redirect from foo.html to bar.html:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^foo\.html$ http://www.example.com/bar.html [R=301,L]
so if i us it in my root directory, does it effect just the index.html or all of my .html web sites. i have a web hosting account and i have many .html web sites off of it. will just one 301 re-direct cover all of my .html sites? i have moved to a different server and i wish to get my web sites that are on search engines to recognize the new server and all my .html web sites.
Note that I said "your Web root directory, as in the directory where each sub-site's robots.txt file would be located.
The details of the answer depend on your exact set-up. If you are using domain forwarding or a "control panel" setup on your old server, then you may need to put an .htaccess file in each sites' subfolder... It all depends on precisely how the old sites are mapped into the filespace of the old server, and whether you have direct access to that "mapping" mechanism. If not, then one .htaccess per site will likely be required.
I should also point out that if your domain names have not changed, then all you need to do is to update the DNS records that point to your old server to point to the new server; You won't need redirects at all.
For redirecting all pages on one domain to the same page on another domain, you can use:
RewriteRule (.*) [new_domain.com...] [R=301,L]
-or-
Redirect 301 / [new_domain.com...]
These are directives of mod_rewrite and mod_alias, respectively, and accomplish the same thing. mod_rewrite is more flexible, while mod_alias is simpler.
Jim