# Redirect from a URL typo

**URL:** <https://forum.kirupa.com/t/redirect-from-a-url-typo/302357>\
**Category:** programming\
**Created:** [December 28, 2009, 7:11pm UTC](https://forum.kirupa.com/t/redirect-from-a-url-typo/302357 "2009-12-28T19:11:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bernielomax](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@bernielomax](https://forum.kirupa.com/u/bernielomax)\
**Post date:** [December 28, 2009, 7:11pm UTC](https://forum.kirupa.com/t/redirect-from-a-url-typo/302357/1 "2009-12-28T19:11:39Z")

</div>

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:

```php

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.
