1

I'm fighting a losing battle over here. I've got an easily misspelled domain name. So I purchased the misspelling. Now, I need to setup the misspelled domain name to redirect everything to the properly spelled domain name, but I need to keep the subdomains.

Example: support.domane.com should redirect to support.domain.com submit.domane.com should redirect to submit.domain.com

I already have a dozen or so subdomains setup for my domain, and I foresee many additional ones in the future. I would really rather not have to input them multiple times across multiple domains.

And I'd really like to have a landing page with a link, just in case the redirect doesn't work. Like an "Update your bookmarks!!1!" page. So, if a solution involves php or javascript, I'm all over that as well.

Any advice would be greatly appreciated.

Thanks in advance,

Critologist

tl;dr I need to redirect domains but keep subdomains intact. http://sub.domane.com -> http://sub.domain.com where sub is a variable and needs to be the same on both URLs.

Critologist
  • 445
  • 4
  • 7

2 Answers2

1

This might help:

https://stackoverflow.com/questions/79764/wildcard-subdomains

What you want is a wildcard DNS A record entry for:

*.misspelled.com

pointing to your webserver.

On the webserver, you want a rewriting engine correcting the misspelling and serving up a 301 redirect to subdomain.correct.com. How depends on what you're running on the server side, but Apache Rewrite rules are common.

I don't know of a way you can also serve up a link - what kind of browser doesn't support redirects? Perhaps if you do it in PHP or similar you can send a redirect response header and a page with a link? Not sure if that can work. - examples: http://www.webconfs.com/how-to-redirect-a-webpage.php

TessellatingHeckler
  • 5,676
  • 3
  • 25
  • 44
  • TessellatingHeckler, that's on the right track. However, since I am using GoDaddy for hosting, and the make me do everything through their web gui, any ideas how to do what you're talking about? I tried adding an asterisks in an A Name entry, but it wanted an ip address instead of a URL. And since I'm using the same ip address for both domains, it wasn't going to work. Any suggestions? Thanks in advance. – Critologist Oct 24 '10 at 16:33
  • A DNS entry to a hostname needs to be a CNAME instead of an A record, but you should be able to do it with an ip address - both on the same webserver won't make any meaningful difference. – TessellatingHeckler Oct 25 '10 at 00:22
1

(Assuming apache is the web server.)

Create a default VHOST with

RewriteRule ^/(.*)$ /foo.php [L]

In foo.php do something like (I don't know php so there is psuedocode):

$server_name = $_SERVER["SERVER_NAME"];

if ($server_name does-not-match "*.subdomane.com") {
  header("HTTP/1.0 404 Not Found");
  exit;
}

$server_name = replace('subdomane.com', 'subdomain.com');

header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $server_name . $_SERVER["REQUEST_URI"]);

exit;

just in case the redirect doesn't work

301/302 redirects work and have worked for a long time.

If you insist though you could return a page that has a link to the non-typo domain and use a meta http-equiv="refresh" or a javascript reload but that is so 1996.

Mark Wagner
  • 17,764
  • 2
  • 30
  • 47