My company sometimes will get a typo in the url from users trying to access the site. We have a domain registered that contains the most common misspelling, and we want users to be redirected to the correctly spelled domain if they misspell the url.
I figured something like:
if (strpos($_SERVER['SERVER_NAME'], 'compny') !== false) {
header('Location: http://www.company.com');
}
would be fine. Or $_SERVER[‘HTTP_HOST’] or whatever. Anything that has the misspelled company name in the string.
However, the company that hosts our stuff does some port translation or something, and echoing the HTTP_HOST returns a numbered IP address, so searching for alpha characters in there is basically useless. Off the top of my head I can’t think of any other solution to this (I’m not terribly knowledgeable with PHP), so here I am.
Anyone have any ideas?
Thanks.