PageRank Preserving Page Redirection

I had a few cgi scripts written in perl some of which don’t even have any parameters and hence are ideal for Google indexing. These scripts had .pl as the file extension and some of them already have a PageRank. However, recently I decided I wanted to have a more generic extension for my scripts, typically .do, so that I have the flexibility of changing them to .php or .jsp or .asp or .py or .rb or whatever technology it is. However, in doing this, I wanted to make sure that the PageRank is preserved. In addition, I don’t have control over the various pages from where I have in-bound links to these scripts. So, I still have to continue to support the old links but with the right PageRank (once Google starts recognizing the new pages).

From Giving search engine spiders direction with a 301 redirect I figured preserving PageRank can be achieved through a permanent external redirection. With this, here is how I went about implementing the strategy.

Below is the .htaccess file

RewriteEngine On
RewriteRule ^(.*).do$ $ [ne]

RewriteCond %{REQUEST_URI} ^.*.pl$
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^(.*).pl$ $ [R=301,ne]

Now, let me explain each of the above.

The first Rewrite rule makes a file with .do to be replaced to .pl which is the actual file in the system. The ne flag is to make it not do escaping of characters.

The second Rewrite Rule (along with the conditions) indicates that if the request uri is using .pl extension but it’s not an internal redirection (from rule 1), then do an external redirection with status code of 301 (permanent redirect). Note that both conditions are needed, otherwise, the rules would go into infinite loop.

That’s it. I just implemented this strategy today. So, will wait and watch for the PageRank to transfer to the new URLs.

If you have a better and efficient way, please post it in the comments section.

BTW, I also use a hosting solution that provides unlimited domains by mapping an internal sub directory for each hosted domain. So, having the .htaccess in the outer most directory, while works for all the sub-directories accessed from the same host, there is a problem with the virtual hosts mapped to sub-directories. It may be possible to come up with a more complex approach by using RedirectBase and some regular expressions and HTTP variables, but for now, I just copied the same exact code to the sub-directory of the virtual host. I would be interested in a solution that takes care of virtual hosts without having to copy to each virtual host directory.


1 Comment

Filed under mod_rewrite, pagerank, SEO

One response to “PageRank Preserving Page Redirection

  1. You currently have a pagerank of 5. : )

    I thought your readers might want to know where they can check their website’s google pagerank.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s