Wednesday, June 29, 2011

Redirects: Permanent 301 vs. Temporary 302

SkyHi @ Wednesday, June 29, 2011
These days, as more and more companies come to the conclusion that their 1990′s built websites with the animated gifs, static backgrounds, and auto-playing midi files have seen their prime, they begin to enter into a world of redesign. While creating these new websites with the sleeker look, and cleaner file structure is a smart move for the future, the risk and complications caused by changing URL’s and the impact this has on search engine rankings is very real.

This is where redirects come in. Using the correct redirect, in most cases a permanent 301, is key to helping maintain your existing rankings, whether your site is undergoing a complete face lift, or if you simply want to move a few pages around.

While Permanent 301 Redirects are the most common there are valid situations where either 301′s or 302′s may be the most appropriate. This article will discuss what these redirects do, common and less common uses, implementation, and how to check that you have set them up correctly

1.) What are these redirects, what do they do?

Permanent 301
To summarize in a few lines, permanent 301 redirects are just as they sound. They are permanent redirects from an old URL to a new one. These redirects tell the search engines that the old location is to be removed from their index and replaced with the new location. Using 301 redirects is the most search engine friendly way to redirect traffic and engines, and far out weighs that of various JavaScript and Meta refresh redirects.

Temporary 302
Temporary 302 redirects are also as they sound; temporary. Here you are telling the search engines to read and use the content on the new page, but to keep checking the original URL first as it will ultimately be reestablished.

2.) Common and Less Common Uses
There are many special cases where you should stand back and consider which redirect to use. In nearly all situations a permanent 301 will be the answer, but sometimes a 302 just may fit the bill. Here are some examples of when to use each redirect.

A.) Permanent 301 Redirects
As noted earlier, 301 redirects are by far the most common. When using them you are telling the search engines “do not come back to this location, the page has permanently moved.”

All three search engines handle 301 redirects the same. If Site A is 301′d to Site B, then Site B will show up in the search results and Site A will ultimately be completely removed.

Page Deleted or Moved
Probably the most common use is the moving or deletion of a single page. Let’s say that you are no longer selling a specific product and therefore have no need for its page. Using a 301 redirect to send the spiders to either the next closest product, or to a relevant product list would be of far more value then having your site return a 404 error and sending users to an error page.

The same goes with pages that are simply moved. While you are probably better off keeping the page where it is, there are many valid reasons why you may need it moved, and in this case a 301 redirect is essential to keep both the search engines, and your site users (who may have bookmarked this old page) happy.

New Top Level Domain
If you are thinking about changing your main domain name, don’t do it. If you find that there is just no way around it, and that the change is essential, 301 redirects are your answer.

By using a 301 redirect to send traffic from your old site to your new site you can help ensure that ranking damage will be minimal. Without a 301 redirect your new site will be a completely from scratch endeavor with years of hard work down the drain and any historic profile that a search engine has created will not be carried over to the new site.

WWW vs Non-WWW
This is now one of the most common uses of a 301 redirect when used in combination with Mod Rewrites. Essentially by using a permanent 301 redirect to send traffic destined to the non www version of your site ( to the www version ( you can focus the strength and prevent page rank split, giving your site’s home page (and internal pages) a nice little boost.

For more information on this specific form of redirect, please see:
How to 301 Redirect Non-WWW to WWW URL’s.

Duplicate Pages
More often than not you will find websites with valid multiple home page URL’s all which serve up the same identical page. This is most common with two versions of the home page such as: and

The first step is to update all your home page links to ensure that only non-index.html version is referenced. Should you happen to miss any home page links, and to direct these /index.html pages to the right place, adding the 301 redirect will ensure that you are not splitting the page value.

Old Domains
If you find yourself with multiple websites and one or more of them are completely outdated, but still relevant and you have no chance of revitalizing it, you may want to consider using a 301 redirect to send traffic and engines to your current site.

By redirecting all internal pages of the old site to the most relevant internal pages of your new site, you will not only ensure that site visitors reach the proper updated content, but that any pre-existing rankings, link value, and other search engine goodness is transferred over to the new, active website.

Note: If you find yourself in the unusual situation of having dozens, or even hundreds of old websites, do not 301 all of them at the same time, you could likely be flagged as a spammer and endure penalties or a possible banning. If this is the case, just redirect a few of your sites that happen to have the most to offer in terms of rankings and traffic.

Rewriting confusing URL strings via Mod Rewrite
Lets say that you have a site with long confusing URL strings for all internal pages. These days the major search engines do a much better job of indexing these obscure file locations, but it is still in your best interest to redirect them to a friendlier, cleaner URL. To do this you can use Mod Rewrites which utilize 301 redirects to turn this:

Into this:

This URL is not only far more friendly to human visitors, it adds a higher level of relevance for the search engines and is easy to index.

(For the record, no, I do not own a white BMW 650, but who wouldn’t want one?)

B.) Temporary 302 Redirects
The practical use of a 302 redirect is really quite limited. In most cases a 301 redirect is the correct choice; however, there are always exceptions. If you find yourself in the position where a 301 redirect just won’t do, here are a few situations where the 302 may be a better choice.

Temporarily Moving a Page
This is the main reason this 302 redirect exists, but you have to also ask yourself, have you ever temporarily moved a page? If the time comes where you need to relocate a page on a temporary basis, with the ultimate final destination of the page being at the original location, then you would want to use the 302 redirect.

Home Page Redirect
Have you ever visited a websites home page only to find that you have been redirected to some obscure URL string like, but in actuality it is still their home page?

There are many cases where various dynamic sites or content management systems choose to rewrite the home page using some lengthy string of variables. The best fix for this is to use a mod-rewrite to change the messy URL into a simple Sometimes however, mod-rewrites may not work due to various server constraints, in which case, using a 302 redirect may be the answer.

By redirecting the home page of your site using a 302 redirect to this longer, more obscure URL, you essentially are telling the engines to continue using the shorter, original URL, but index and rank based on the content of the longer version.

In doing so you will not only clean up the display URL in any search engine rankings, but you will also help retain value from any links pointing into your home page from outside sources, ultimately helping to improve your overall search engine rankings.

Special Promotions
Let’s say you have decided to create a special promotion for a product page on your site. You have toyed with the idea of changing the original product page but have decided against it, and instead created a new promotional page.

While the promotional page is live, use a 302 redirect to temporarily send traffic intended for the product, over to the promotional page, you can then easily remove the 302 redirect once the promotion is over and the original page will come back into play.

302 Hijack
Important Note: We do NOT recommend attempting this, although if you do, you are likely to only harm yourself as this black-hat trick no longer works.

Not too long ago the spammers did what they are good at and found a way to abuse the system, in this case, the 302 redirect.

It was possible to use these 302 redirects to hijack rankings and traffic from another unsuspecting site. How did they do it?

Hackers used the 302 redirects to send the search engines from their domain (Site A) to a page on the target domain, (Site B). Google would see this and the rankings for Site B would be ultimately transferred over to the redirecting page on Site A.

Spiders were essentially cloaked to see the 302 redirect to the page on Site B, while human visitors, arriving from the newly hijacked rankings, would either see the original page, or be directed to another page residing on Site A.
302 Hijack

Because of this vulnerability any 302′s that direct to a different top level domain are now treated as 301 redirects by the search engines. By treating these as 301 redirects it eliminates the usefulness of this technique and solves the hijacking problem – sorry spammers.

Special Circumstances
There are always exceptions to every rule and situations which result in the need for a creative solution. In the past we have had a client who found themselves in one of these situations.

When undergoing a huge redesign, a client of ours was forced to have part of their site hosted on one server, and part on another. The part of the site to be moved also had to be placed at the sub domain www1. This presented the potential problem of a huge ranking loss in the search engines which just was not acceptable.

The answer was using 302 redirects on all pages which were moved over to the www1 location. Because the sub domain is still a part of the original top level domain, this solution did not risk any possible penalties from the search engines (in regards to the 302 hijack issue), and also did not cause any problems with the effects of the alternative; a 301 redirect. In the end not only were rankings not compromised, the result of the new website actually caused an overall improvement in listings and site traffic.

This was a circumstance with a number of complicated technical issues I won’t go into, but the end result was success, with much thanks to a few 302 redirects.

3.) How to Implement:
The focus of this article is about understanding the difference between these two redirects and which one is right for you. If you need help on the implementation of these redirects visit our tutorials found at:

How to Redirect an Old Domain to a New Domain
How to Redirect Non-WWW to WWW URL’s

4.) How to Check:
Not sure if you have implemented your redirects correctly? There is a fast and easy check you can do to find out.

Let’s say you are redirecting page A to page B. The obvious way to check is to try loading page A and see what comes up in your browser, but, if you have set up the wrong redirect, to the naked eye it may appear that all is correct.

To ensure that the correct status code is being utilized, use a “header checker” tool, enter the URL for the page to be redirected, and see what comes up. Finding a tool to do this is as simple as searching in Google, but to make things even easier see our HTTP Header Checker tool at StepForth.

5.) 301 / 302 Redirect Warning
Be sure to avoid redirecting large numbers of pages all to one location. This practice is commonly used by spammers and could wind up getting your site into some hot water with Google.

Spammers have been known to create thousands of pages. By generating 1or 2 links to each of these pages, and ensuring that they are spidered and indexed in Google they can then harness the power of redirects to boost site rankings. By taking thousands of pages and redirecting them all to one main page, you would essentially increase the value of the target page and transfer much of the link popularity and boost search engine rankings.

Google is onto this. If you try this, you will likely end up banned, or at least penalized. That said, there may be legitimate reasons why you would drive multiple pages via 301s to another page on your site. If this is the case, be careful so you do not wind up being flagged as spam.

6.) Summary
If your site is in need of a redirect, be sure to use the appropriate one for your situation. Correct use of these redirects can be your best friend when it comes to retaining search engine rankings, and your worst enemy if used incorrectly. There are many situations which may not be covered in this article, but hopefully you now have the information to make an informed decision on which of these two redirects is right for you.


PHP refresh / redirect to an external web page

SkyHi @ Wednesday, June 29, 2011
//  refresh / redirect to an external web page
//  ------------------------------------------
header( 'Refresh: 10; URL=',TRUE,301 );
echo ' is now -- your browser will be redirected in 10 seconds';

Old domain to new domain permanent redirection

SkyHi @ Wednesday, June 29, 2011
Domain name redirection

Why to redirect domain name?

When webhost is changed (moving site), there is no problem to point domain to new server, just changing DNS. When new domain must replace old domain, then could be a problem with search engines. Two domains leading to one site, it means duplicate content, and duplicate content for search engines is not acceptable, both your domains could be penalized or, worse, banned from search engine listing.

To avoid duplicate content penalty, you need to "tell" search engine spider, that your site is moved on new domain, (i.e. you need to use redirect from old domain to new).

Instead of old way with redirection pages, better is to use a permanent (301) redirection.

Simple way to do that is to use htaccess redirection - mod rewrite (apache server)

Case One: old domain to new domain - same hosting account

New domain to replace primary domain? You can't do that. Primary (main) domain is connected with your hosting account, and all add-on and parked (alias) domains are connected with your main domain. If hosting is good, and you want to keep it, you can contact support, they can do that. So, old domain could be parked, and new domain set as primary domain (account moved).

Anyway, if you wish to try, you can set new domain as "main domain", there are two ways:

Using parked domain as main domain

Parked domain (alias) is pointing to root (only if parked on your account), what means, it is the same as main domain. It could be used as "main domain" on your account, if traffic from your old domain is redirected (permanent redirect). It is not problem, but, you still need to keep your old domain, it is connected with your account, and if it is removed (or expired), all other domains (parked, ad-ons) will disappear. So, keep your primary (old) domain in good health.

In this case (alias as main domain), it is not neccessary to move any page from your site, but it is neccessary to remove any instance of old domain from page. If you are using relative linking (without full url), you don't need to change anything. In this example below, we are redirecting our primary (old) domain to new (parked, alias) domain.

#Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^$[OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [R=301,L]

Now, with this setup, every request for is permanently redirected (301) to, About htaccess, and how to add this code above, see on bottom.

There is one problem with this setup. If your stats or logs are on, you need to disable redirection (uploading old htaccess) at that moment. Due to redirection, your stats directory is "moved" to,and you will get login screen again.

Using Add-on domain as main domain

Difference from parked domain (alias) is that add-on domain is pointed to subdirectory of main (primary) domain, (i.e. is pointing to, while alias is pointing to root. In this case, we need to move (copy) all files to /addondomain/ directory of main domain and add redirection from root to /addondomain/.

Code is the same as above for parked page, just be sure that everything is working on add-on domain before old domain is redirected.

Anyway, you should ask your hosting support is this above possible. You can test redirection to check is it working, but not all servers are the same, so, first ask support.

Case 2 (best): Old domain to new domain - different accounts

This is the best way to change domain name. Set up new account, host new domain on that account, test if everything is working, and add redirection from old domain (account). Keep old domain and account for a few months, or for a year, leaving redirection on place.

When you are sure that new domain is indexed on search engines, and google PR updated for new domain, and there is no links to old domain, and redirected visitors, you can do with old domain and account what you wish.

Sure, htaccess code (directives) is the same as above.

Subdomain to new domain redirection

Say that you have popular site on subdomain, and wish to move to the new domain on other account. Just use code below.

#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule (.*)$$1 [R=301,L]

That code could be used if you have account without domain (your account is connected with, just add new domain to the same account, and use above redirect.

Non WWW to WWW version redirection

Believe or not, there are still sites you cannot reach without using www in domain name. That is server configuration "problem", but what if you find that your site is indexed with two "domain names", with and For search engines, these are still two different sites with the same content. This happens when your link partners are using version without WWW. Search engine spiders are following those links, and in that case your site is indexed without WWW. Although you can check on YAHOO Site Explorer who is linked to your site and what version of domain name they are using, it is better to add redirection to WWW version. Working example, tested.
Uncomment first line if you have any problem.

#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^
RewriteRule ^(.*)$1 [R=301,L]

WWW to NON WWW version redirection

If you prefer non WWW version of domain name, code is below:

#Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^
RewriteRule ^(.*)$1 [R=301,L]

To test it, just add www. in front of domain name in browser address bar, and you will be redirected to non WWW version.

One version of domain name will boost your Google PR.

Other examples of domain redirection

All pages from old domain to main page (root) of new domain:

redirect 301 /

More examples soon...


Whatever example you wish to use, don't forget two things. Htaccess is a text file, it must be uploaded in ASCII (text) mode, not binary. It will be good to keep it offline with .txt extension, to be sure that will be uploaded in ASCII mode. Don't forget to rename it to .htaccess after upload. Second, always test it.

To avoid any interruption during testing, keep two versions of htaccess, i.e. htaccess_redir.txt and htaccess_original.txt. Upload htacces_redir.txt, rename it to .htaccess, and with opened FTP program, test domain name redirection in browser. If it is not working (server error 500), upload original file back (htaccess_original.txt) or edit and try again.

Use some online header checker (or check in website log) to confirm that server response is 301 (moved permanently). AND, do not promote new domain (if content is the same) before redirection from old domain is on place.

Search engines and 301 redirection - example

In recent experiment (Feb 2007) main domain was redirected to alias domain (same account - IP). That site is small (30 pages), it was easy to track indexing under new domain. So, month later, here is situation:

Google - new domain indexed, old domain deindexed, rank lowered (domain is new) PR 0 (3 before)
Yahoo - new domain indexed, old domain - a few pages left, indexed under both domains, rank lowered
MSN - No sign of new domain, all pages still indexed under old domain, cache shows redirect (document moved here)

What about traffic from search engines? If you are redirecting old domain to new domain, your search engine position will change. Not only due to different domain name (keyword), other factors are involved too. One month is small time frame to get things on place again. When you are sure that pages are indexed under new domain, replace/edit/ask links from other sites.

Update May 2007 : After last Google PR update, new domain has PR 2 , all pages indexed, old domain could not be found. For PR 2, we can talk about good internal linking, not that PR is transferred to new domain. New domain is new domain.
YAHOO: Old domain removed, new domain indexed. Pages are slowly getting positions where they were before, under old domain.
MSN is still waiting for something. New domain still not included in index, and main page (only that page) is still indexed under old domain. According to above, I am not sure how MSN spider is handling with 301 redirection.

Update Jun 2007 : End of experiment, no success. While google has all pages indexed under new domain, Yahoo don't want to listen. Main page and a few others are again indexed under old domain (redirection was on place all the time.). MSN still refuse to index new domain, keeping main page indexed under old domain. Since many links are still pointing to the old domain, now the new domain is redirected back to the old domain. New domain AND new hosting account is still the best solution. This example is from 2007, it exist possibility that, at time when you reading this, things are changed, even then, be carefull.

Moving site from free hosting to new domain

This is not a permanent redirection, here is META tag used to redirect old page to the new page on new domain. So, if you still have an old site hosted on "free" hosting, and want to move that site to new domain, make and upload (different) page with the same name, add redirection META tag with 10 - 15 seconds, add page moved, bla, bla... in body, with link to, and your new site will be indexed fast. Maybe will a problem with duplicate content for the first time, but that will disappear after search engine database update. Old site will remain in index, so you can use it to to get other new site indexed faster, or add some other content there. Google "page moved" or "site moved", and you will see some examples how to do this kind of redirection.

Using this "redirection" new site (domain) was indexed from Google and Yahoo fast, but two months later, domain still could not be found using MSN search (although spidered).
Update: It is fully indexed after three months.

BASE HREF tag and search engines

Base href META tag is useful when you are using relative linking on site (i.e. ../index.html instead of When that tag is added to pages on new domain, it helps search engine spiders to determine real website domain.

So, it will not hurt when it is used in combination with domain redirection. Include domain version (with or without www) and page:

<base href="">

For main page (or subdirectory index page) could be added without page name (don't forget slash on the end):

<base href="">


Add more domains to one hosting account example
Hide affiliate links using htaccess

Fix: Screensaver Freezes in Ubuntu 11.04

SkyHi @ Wednesday, June 29, 2011
Lately I have been facing some issues using Ubuntu 11.04, one of them is the freeze which occurs once a while when screensaver is on. I tried all sorts of tweak in gnome power manager but there was no use. I then replaced Gnome-Screensaver with xscreensaver and finally it worked.
Here is how I did it to fix . Just follow this simple steps and hope it fixes your issues.

Step 1
Open the terminal and enter the following code to remove Gnome Screensaver
 #sudo apt-get remove gnome-screensaver

Step 2
Open Administration -> System Monitor and find the process “gnome-screensaver” and  it

Step 3
Install xscreensaver, type the following in the terminal
#sudo apt-get install xscreensaver rss-glx xscreensaver-gl xscreensaver-data xscreensaver-gl-extra xscreensaver-data-extra

Step 4
Open Preferences- > Screensaver,when prompted to start xscreensaver daemon, allow it


CentOS 5.6 unexpected inconsistency how to repair?

SkyHi @ Wednesday, June 29, 2011
This morning I found that my server was not responding and wasn't able to connect to it in anyway to do a safe reboot. I had to do pull the plug to reboot. Upon rebooting everything appeared to be normal up till booting CentOS. Below is a screenshot of what I have.
CentOS file system error
The HDD's are not reporting any errors so this appears to me that something has corrupted. I haven't a clue what to do next. How can I get this system back up and running?
The server is only used as an rsync offsite backup drive. Reinstalling is an option but only as a last resort as the server is holding 1TB of backup data and to re-sync that it would take a month to do over our office connection.

You've experienced some filesystem corruption. From where you are, you can probably run fsck -y / to kick off the process of filesystem repair, based on the image you attached. The -y answers yes to the questions the fsck command will probably output. Try this first.


Tuesday, June 28, 2011

.ogv video does not display with <video> tag in Firefox 3.5

SkyHi @ Tuesday, June 28, 2011
I was trying to take advantage of that new HTML5 <video> tag, and Firefox 3.5's native Ogg support, by embedding an .ogv video. Here is the references I used:

You need to make sure you your web server is set-up with the correct MIME types. Otherwise, Firefox 3.5 will not show the video.

I found the following at and it worked for me. Add the following to your .htaccess file:

AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/x-m4v .m4v

The Camen Design site has a good overview of using the <video> tag with a Flash fallback (for browsers that don't use the <video> tag). Hope that helps.