Forum Moderators: buckworks & webwork

Message Too Old, No Replies

301 redirect for Parking domains on the same IP as a Live site

         

blainehilton

12:04 am on Dec 12, 2002 (gmt 0)

10+ Year Member



I have a website and I have registered it in the domain names that are avaiable. However I have just parked all of the domains on top of mydomain.net which is my "main" domain. All of my promotion and everything is with the .net domain and its doing pretty good with a total of 179 incoming links so far and I'm ranking in the top 5 for many of my key phrases.

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]

Lisa

12:39 am on Dec 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you use a scripting langauge on your first page, you could do something like this at the top of the document...

<?
if( strtolower($HTTP_HOST)!="www.mydomain.net" ¦¦
strtolower($HTTP_HOST)!="mydomain.net" ){

header("Location: [mydomain.net");...]
exit;
}
?>

Marcia

12:52 am on Dec 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a way to do it with .htaccess/mod_rewrite that would return a 301?

jdMorgan

1:04 am on Dec 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Blaine,

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]

This says, "If the domain name used to get to your site was not www.yourdomain.net, then redirect to www.yourdomain.net." As long as the domain names in the first and last lines are the same, it'll work - with or without "www." - your choice. (The backslashes in the domain name/IP in the first two lines are required to designate the periods as literals)

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

blainehilton

1:27 am on Dec 12, 2002 (gmt 0)

10+ Year Member



Thanks for the great responses! The scripting answer sounded good, but I wasn't sure how the search engines would like it. I did use the .htaccess method though and it worked great, plus I don't have to enter every single domain myself!

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?

jdMorgan

1:55 am on Dec 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Blaine,

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