Can I get my browser to automatically redirect on some pages?

Is it possible to have a browser (firefox or chrome), when I navigate to a specific page, the browser automatically redirects me to a different page of my choice. I'm wondering if there is some sort of browser extension to accomplish this. Ideally, I would specify a trigger url, and then a redirect url for each of the different redirections that I would want to define.

Clarification: I do not host the webpages i wish to redirect. I want to redirect the pages just on my browser. For example, when I type www.yahoo.com, I want my browser to go to www.google.com instead.


Solution 1:

Redirector: Automatically redirects to user-defined urls on certain pages

You can specify patterns for pages that should be automatically redirected to other pages. E.g. you always want http://example.com/foo.html to redirect to http://example.com/bar.html.

This can be useful for instance to skip confirmation pages after posting messages on message boards, skipping ad pages that appear before you can view content on certain sites, redirecting from http to https on sites where you always want the https version, redirecting from one hostname to another for proxy servers, or just anywhere where it takes you two or more clicks to get to what you want.

The extension supports both wildcards and regular expressions in patterns. Regular expressions support capturing parantheses so you could define the pattern: http://foo.com/bar.php\?id=(\d+) and define the redirect as http://bar.com/baz.php?id=$1. In that case http://foo.com/bar.php?id=1234 would automatically redirect to http://bar.com/baz.php?id=1234. As of version 1.5 wildcards can also use $1,$2 in the redirect urls, $1 is the contents of the first star match, $2 of the second and so on.

To add a new redirect, right click either anywhere on a page and click 'Add current url to Redirector' or right click on a link and click 'Add link url to Redirector'. You can also add urls from Tools->Redirector->Add... but then you won't get the example url filled in.

To edit and delete redirects, goto Tools->Redirector, or choose Options on the Addons window.

To disable Redirector temporarily, click on the R that's in your statusbar or press alt+r. Right clicking the icon opens the Redirector options window.

Solution 2:

You can also use the system HOSTS file, but that only works for entire domains. Or you could set up a local DNS+webserver, and create redirects for the websites and urls you want via the DNS and maybe PHP or another scripting language.