When performing Website Audits I will almost always find that the website’s IP address doesn’t have a 301 redirect. This is known as an IP Canonicalization Test, which about 80 to 90 percent of the websites I audit fail.
Testing Your IP Canonicalization
When performing website Audits, I like to use either of the following companies website audit tools.
As part of the audit, the tools will perform a IP Canonicalization Test. Another way to perform the test is to simply enter in the ip address and see if it redirects you to the right URL. If not, you know you have a problem.
IP Canonicalization Test
Matt Cutts from Google has an article that talks about URL Canonicalization.
Luckily the IP Canonicalization test failure is an easy fix and amounts to adding 2 lines to the .htaccess file. Apple Mac users are going to have a little problem modifying this file because in the Mac world, .htaccess files are hidden.
The following information is based on 3 asumptions
- You are using WordPress
- You are using a Mac
- You have access to the website Server
Since I don’t own a windows operating system and don’t plan to, you will have to adjust the information I provide for your operating system.
Unhiding .htaccess files
There is no user friendly way of changing the AppleShowAllFiles parameter, which would show all the files on the Mac computer. You must use the Apple Command “Terminal” application located in the Applications –> Utilities folder. The file you will need to open on is called “Terminal” Start by opening Terminal.
When the Terminal opens type the following
- defaults write com.apple.finder AppleShowAllFiles TRUE
- killall Finder
The “defaults write com.apple.finder AppleShowAllFiles TRUE” statement shows hidden files.
The “killall Finder” statement will restart the Apple Finder program with the new file instructions.
This will restart the Finder with the new value of the AppleShowAllFiles parameter.
Now any file that starts with a “.” dot character should now be visible. You can now find and modify the .htaccess file.
Copying the .htaccess file using FileZilla
The .htaccess file should be located in the root directory of your WordPress
.htaccess 301 Redirect
In order to pass this test you must consider using a 301 re-write rule in your .htaccess file so that your site’s IP points to your domain name.
If your site is running on apache server, you could put these lines in your .htaccess after RewriteEngine on line:
RewriteCond %{HTTP_HOST} ^XXX\.XXX\.XXX\.XXX RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L] So for example my website http://hangtenseo2.wpengine.com has an ip of 198.71.233.5 The rewrite code would look like RewriteCond %{HTTP_HOST} ^198\.71\.233\.5 RewriteRule (.*) https://hangtenseo.com/$1 [R=301,L]
Note: You must proper format the first line using your IP (replace X characters with proper digits from your IP) and the second line using your domain name.
Reseting the Mac file structure and hiding .htaccess files
Once your done modifying the .htaccess you can reset the hidden file functionality by reseting the Finder to not show hidden files
Run the Terminal again and type the following
- defaults write com.apple.finder AppleShowAllFiles FALSE
- killall Finder
we added this code to .htacess file but it’s not working how can rectify this….??
Useful article and it has so much potential and as a seo analyst i know its value for seo ranking factors
we added this code and its working, have to wait and see if seo score will get or not
Very Interesting Article. This Kinds Of Information Is Very Help Full For Digital Markets.
I am a digital marketing trainer and Marketer.I’ll tries this tip.if it is working I will suggest to my students and coworkers
Does this really works anyways still added to my website…
This article is very nice.
artificial intelligence
Superb! Your blog is incredible. I am delighted with it. Thanks for sharing with me more information.
Hi Tom,
Very informative blog post on htaccess file.
Hello Admin,
Thank you for shearing this valuable information!