Forum Moderators: phranque

Message Too Old, No Replies

Working with typo domains

Properly redirecting traffic

         

ocon

2:53 am on Apr 13, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have one domain name, let's say its example.org, and on this domain I use lots of folders as well as sudomains:

sub1.example.org/folder1
www.example.org/folder2
sub2.example.org/folder3

In addition to example.org, I have several other domain variations:

example.com
exampel.org
exampel.com

What I want to do is to forward any traffic from one of these typo domains to the proper file in the correct subfolder/folder.

I'm thinking I need to setup a folder on my hosting account that all the typo domains point to, (outside of the folder where I host example.org). Then, I need to go through each typo domain and create wildcard subdomains.

I guess inside this folder, I need something like an .htaccess file that detects the subdomain, folder, and file path being requested, correct the domain to example.org, and use a 301 redirect to move the user to the correct location.

Would this be the best approach, or is there something better to do?

I understand that if the user types in randomsub.exampel.com/randomfolder that they would be redirected to randomsub.example.org/randomfolder, where their request will fail, but I would rather it fail on the correct domain than have some kind of filtering/error system on the typo domain.

Also, what would be the best approach to handle email settings on the typo domains? Would I change MX records, or anything?

Thanks

g1smd

3:37 am on Apr 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



More detail is needed as to URL patterns that do NOT need to be redirected as well as a bit more detail about those that do.

It's likely just a few lines of code will do exactly what you want, and it is also likely you'll need no extra hosting at all.

Coding cannot begin until all the requirements have been fully thought through, documented, and kicked around looking for flaws.

ocon

4:23 am on Apr 13, 2010 (gmt 0)

10+ Year Member Top Contributors Of The Month



I don't think I'll have any URL patterns that do not need to be redirected, because everything should be redirected; its a mistyped domain.

I'm not too sure on how to do this, but I imagine its going to be along these lines:

RewriteEngine on
RewriteRule (.*) http:// (REQUESTED-SUBDOMAIN) \.example\.org/$1 [R=301,L]

I know I want to do some rewriting, so I turn the rewrite engine on.

As far as the rewrite, I think I want to match everything.

I'm not too sure about how to insert in the requested subdomain (and what's going to happen with that leading period if they don't specify one).

Then I have the correct domain, and a variable of the requested file path using a 301 redirect.

jdMorgan

2:45 pm on Apr 13, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A lot depends on how you set up your server (perhaps using cPanel) to "map" domains and subdomains to folders.
You could simply map all typo-domains and all of their subdomains to *one* folder, and then use code in a .htaccess file in that one folder to sort them all out.
This part of the plan needs to be fully thought-through --and even tested-- before you proceed to coding details, otherwise you will likely waste a lot of time and effort...

You can test for requests for specific domains and subdomains.
You can test for requests for NOT specific domains or subdomains.
Using both positive- and negative-matching will likely lead to the most efficient solution.

Jim