I'm writing this blog post in regards to my latest one - why? Well, I installed WordPress on my VPS (here) and now I've associated Google Analytics and Google / Yahoo & Bing WebMaster portals with the domains (more to come on these...)

As a side, you'll probably or have already figured out that I'm really into analytics, search engine optimization (SEO), and all things web dev alike...but thats not my point. I installed WordPress on the Digital Ocean, updated my .htacces, and did the whole robots.txt thing...but my URL is still being indexed by Google at the IP-Address level.

Let the Googling (or insert your favorite Search Engine here...btw, check out DuckDuckGo) commence. If you've done this as I have you'll notice people talking about URL shortening, IP Addresses displaying in URL bars, improper read / write permissions setting the IP Address or even other items that could possibly be associated with IP address in the URL (nav bar). I hate nothing more then searching the internet (muawhawha) and finding that there is NO value in the crap that I'm reading.

So let me stop with my tangent and just provide you with the answer. A simple change to the .htaccess file can be a life saver. Using Apache WebServer, I added the following lines to my .htaccess and wah-la done:

RewriteCond %{HTTP_HOST} !^viktorjagar.com [NC]
RewriteRule ^/?(.*)$ http://viktorjagar.com/$1 [L,R=301]

Reminder that this will send your site to my site - so you should enter the correct information in the domain field of the condition / rule. This means that anyone trying to access the IP address will be redirected to the viktorjagar.com domain. Now let the waiting commence...Google / Yahoo & Bing now have to re-crawl and ensure that the IP address shouldn't be shown and instead the domain-name should be.

As a side, the 301 is the correct implementation of the redirect that we needed. 301 SEO-wise will pass over 99% of the link juice (which for this site is roughly 3 weeks of indexing) over to the viktorjagar.com domain.