Testing .htaccess 301 Permanent Redirect Works

This is a follow up post to the blog Domain parking with 301 redirect. This blog will show you how to test that things are working correctly. Of course, you could just type in the domain which must redirect and then when it does redirect to the main domain you have a fairly good idea its worked, but you may want to double check what’s actually happening.

To do that, we’ll look at the HTTP headers sent back from the web server. There is more than one way of doing this, I’ll only show one of them, but feel free to leave a comment if you have a different method.

We’ll use telnet to access our web server, much the way your web browser does behind the scenes.

Step by step guide to use telnet to view HTTP headers:

In this example, our main domain is PHP-Web-Host.com. We have a secondary domain name, softsmart.co.za which redirect to PHP-Web-Host.com, so you’ll obviously just need to change the domains you use to suit your own use.

1) Open a command prompt. In windows, you can do so by clicking on the programs menu or by typing cmd into the run box, and pressing enter.

Command Prompt

Or by typing cmd:

cmd

In the command prompt window, type “telnet softsmart.co.za 80″ and press enter, without the quotes and putting your secondary domain name in there instead of ours (it will still work as an example if you use ours:

 

Telnet

 

 

As soon as you hit enter and it connects to the web server, the telnet window will go blank. It will stay blank so you won’t be able to see what you’re typing, so type very carefully.

Type “GET / HTTP\1.1” and press enter (again, without the qoutes)
Now type “Host: softsmart.co.za” and PRESS ENTER TWICE!!!! (again without the qoutes!!!).
You should now get a reply from the web server which looks similar to the following:

 

HTTP_Reply
Notice in the headers section highlighted above we see “HTTP/1.1 301 Moved Permanently”, as well as “Location: http://www.php-web-host.com”. That tells us that the web page is being directed with a 301 permanent redirect, which is exactly what we want for SEO!

We’re now confident that our 301 has worked, YAY!

Please leave your comments or questions below, we love to hear from you. If you use a different method to achieve the same thing we’d like to know too…

facebook google twiter linkedin linkedin linkedin linkedin linkedin

Leave a Reply

Current month ye@r day *