I do not want to mess up my standings with the search engines though and lose my work. After reading everything here and doing searches it seems I should switch to using 301 redirects.
My question though is do I keep all of the domains parked and just create a line like this:
Redirect [mydomain.us...] [mydomain.net...]
Would that work if I did that with all of my domains and with out the www? Or do I need to setup actual hosting accounts for each domain and then use a line in each domain's .htaccess?
TIA
Blaine Hilton
[edited by: Lisa at 12:34 am (utc) on Dec. 12, 2002]
[edit reason] no specific domains please [/edit]
<?
if( strtolower($HTTP_HOST)!="www.mydomain.net" ¦¦
strtolower($HTTP_HOST)!="mydomain.net" ){
header("Location: [mydomain.net");...]
exit;
}
?>
Welcome to WebmasterWorld [webmasterworld.com]!
Assuming you're hosted on an Apache server, all you need to do is to add the following lines to the .htaccess file in the site's root directory, and then update your DNS records to point to your .net site's IP address:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.net
RewriteCond %{HTTP_HOST} !^123\.45\.67\.89
RewriteRule ^(.*)$ http://www.yourdomain.net/$1 [R=permanent,L]
Including your IP address in line 2 simply allows you to access your site by IP address in case of a DNS failure. It's not necessary and can be omitted, but it's nice to be able to access your site and make sure it's a DNS problem, rather than a server problem.
Add the code above before changing your DNS - It will save a lot of work if it turns out that mod_rewrite [httpd.apache.org] is not available on your server. You can add the code exactly as-is for testing - it won't matter that the domain name and IP address are wrong for this test. If you can still access your site through http without a 500-Server Error after adding the code, then it's likely that mod_rewrite is installed and available to you. If you do get an error, check your error log to see what the problem was.
If it works OK, then modify the code to match your domain name and IP, re-upload your .htaccess file, and then change your DNS. If all is well, then any time you use a legal-but-nonstandard variant of your domain name to access your site, your browser address bar should update itself and show your standard domain name.
HTH,
Jim
I was wondering about the performance hit that everyone seems to mention when talking about using this method though. After reading through the other posts here and some other websites it seems like the performance hit is very small. Should I be concerned though?
I wouldn't worry about it unless you're getting 100,000 hits a day or more. The snippet of code I posted is only about 2.5% of the length of my .htaccess file, and I don't see any noticeable performance hit. I have a couple hundred more lines in there that enforce user-agent exclusions, block IP addresses of known troublemakers, and redirect requests for obsolete pages, etc. But it's still invisible in the site's response time.
The impact will vary depending on how busy your site is, but this is usually a really small factor.
Jim