Determining the type of redirect in use
Posted by John Mueller on March 9th, 2007
Website redirects can be hard to check - and they can have an influence on crawling and indexing. Search engines can follow [301] and [302 server side redirects] as well as meta refresh redirects. They can not follow [javascript redirects].
If a redirect is made within your site, it is vital that you confirm that the redirect is exactly how you need it to be.
Confirming a server side redirect
There are several methods to determine which kind of server side redirect is being used:
- Use an online server headers tool
There are many tools available - one of them is at oy-oy.eu. Give the tool the original URL of the page you need to check and submit it. The tool will display the result codes returned from the server - if a server-side redirect is being made, you will see it. - Use Firefox with the Live HTTP headers plugin
Open the Live HTTP headers window (usually menu Tools / Live HTTP headers), enter the original URL into your browser window. All HTTP headers will be shown in the window. The redirects will also be visible here. However, if you have many elements on your web-page (graphics, external scripts / stylesheets, Adsense, etc) then you will see all of those in the window as well, making it harder to find the redirect - it is usually the first entry in the list. - Use “wget” to access the page
Wget is a free command line tool that can be used to download web-pages. Wget is available for almost all platforms (including Windows). You can invoke wget to check a page like so:
wget -S “http://mydomain.com”
Optionally you can specify a specific user-agent (eg the Googlebot) to confirm that the Googlebot would receive the same redirect:
wget -S -U “GoogleBot/1.2 (+http://www.google.com/bot.html)” “http://mydomain.com”
Some example redirects to use as tests:
- 301 redirect: http://oy-oy.eu/test/301.aspx
- 302 redirect: http://oy-oy.eu/test/302.aspx
Confirming a meta-refresh redirect
In order to confirm a meta-refresh redirect you need to access the page that is doing the redirect. It is a good idea to confirm that the page is not doing a server side redirect first. The easiest way to do this is to use Firefox WebDeveloper plugin. This plugin will let you disable meta-refresh redirects.
You can disable the meta-refresh redirects by opening the menu “Disable” (in the WebDeveloper plugin) and selecting “Disable Meta Redirects”.
Once meta-refresh redirects are disabled, you can enter the URL of the original page into your browser. Firefox should now stay on that page. You can now use menu “View” / “Page Source” to examine the HTML source of the page. It should have a meta-refresh redirect visible in the head-section of the page:
<html><head> (…)
<meta http-equiv=”refresh” content=”0;url=http://www.greatnewsite.com/”>
<head>
(…)
The number right after “content” and before the URL is the time which the browser waits before redirecting. Times below 5 seconds are treated as a 301 redirect, times above are treated as a 302 redirect (in general).
An alternate method would be to download the page in question with wget and to analyze the source code in an editor.
Confirming a javascript redirect
Javascript redirects can also be confirmed with help of the WebDeveloper plugin. It is also a good idea to confirm that the page is not doing a server side redirect first. A simple way to confirm that a page is doing a javascript redirect is to make sure that you have meta-refresh redirects enabled, turn javascript off (in the WebDeveloper plugin: “Disable” / “Disable Javascript” / “Disable All Javascript”) and to go to the URL in question. The URL should remain - it should not redirect. Now enable javascript again and use “Refresh” (F5) in the browser to refresh the page. If the redirect is in javascript, the browser will now redirect to the new URL.
To be certain about a javascript redirect (and to determine how it is done / triggered) it is necessary to examine the javascript code that is being processed on the page. This is generally not trivial.
Keep in mind that search engines cannot parse javascript redirects - they will not find the new page. In addition, it is possible that search engines recognize potential javascript redirects (even if they cannot parse them) and assume it is an attempt to manipulate the user; to issue a “sneaky redirect” - if this is the case with your page (and if it is doing a sneaky redirect) it is possible that your site is penalized or even banned from the index.
April 4th, 2007 at 5:15 pm
[…] Determining the type of redirect in use […]