Redirector

243

Redirector is a browser add-on for Firefox, Chrome and Opera. The add-on lets you create redirects for specific webpages, e.g. always redirect http://bing.com to http://google.com.

redirector-logoThis simple extension allows you to redirect urls using the power of regular expressions.The redirect patterns can be specified using regular expressions or simple wildcards and the resulting url can use substitutions based on captures from the original url. The add-on can for example be used to redirect a site to its https version, redirect news paper articles to their print versions, redirect pages to use specific proxy servers and more.

What is Redirector?

Redirector is a browser extension that allows you to automatically redirect from one webpage to another. For example, every time you visit http://abc.com you will automatically load http://def.com instead. This can be useful for instance to always redirect articles to printer friendly versions, redirect http:// to https:// for sites that support both, bypass advertising pages that appear before being able to view certain pages and more.

Go WHere You Want To

A new feature in v3.0 is that the result of a redirect will never be redirected again, even if it matches another include pattern. This is to prevent endless loops, for example if you have a pattern that redirects from a -> b and another that redirects from b -> a. This also removes the annoying message that the include pattern matches the result and therefore you can’t create the redirect. That doesn’t matter anymore because the result will never be redirected, even if it matches the include pattern again, so this should make it simpler for people to create redirects.

Daily Usage

1. Tumblr High Quality Image

Example URL: https://67.media.tumblr.com/6a7dcbe2b7812b81badb58123ca90c21/tumblr_ods4l2p1ey1sutgy1o1_540.jpg
Include pattern: http*://*.media.tumblr.com/*/*_*_*.jpg
Redirect to: https://$2.media.tumblr.com/$3/$4_$5_1280.jpg
Pattern type: Wildcard
Example result: https://67.media.tumblr.com/6a7dcbe2b7812b81badb58123ca90c21/tumblr_ods4l2p1ey1sutgy1o1_1280.jpg

2. Skipping localized Version of site

Say you enter google.com, but are taken to google.co.uk instead, or the redirect on Gizmodo that is taking you to the localized version of the site if it exists. While it is usually possible to switch back by changing the country selector or making other configuration changes, it is a nuisance, especially if you explicitly enter the url you want to go into the address bar.  Lots of websites and services are out there that redirect you automatically based on your location in the world.

redirects-in-wordpress

Examples

  1. Static redirect
    Example URL: http://example.com/foo
    Include pattern: http://example.com/foo
    Redirect to: http://example.com/bar
    Pattern type: Wildcard
    Example result: http://example.com/bar
  2. Redirect using query string parameter and wildcards
    Example URL: http://example.com/index.php?id=12345&a=b
    Include pattern: http://example.com/index.php?id=*&a=b
    Redirect to: http://example.com/printerfriendly.php?id=$1&a=b
    Pattern type: Wildcard
    Example result: http://example.com/printerfriendly.php?id=12345&a=b
  3. Redirect using query string parameter and regular expressions
    Example URL: http://example.com/index.php?id=12345&a=b
    Include pattern: http://example.com/index.php?id=(d+)&a=b
    Redirect to: http://example.com/printerfriendly.php?id=$1&a=b
    Pattern type: Regular Expression
    Example result: http://example.com/printerfriendly.php?id=12345&a=b
  4. Redirect to a different folder using wildcards
    The exclude pattern makes sure that there is only one folder there, so for instance http://example.com/category/fish/cat/mouse/index.php would not match.

    Example URL: http://example.com/category/fish/index.php
    Include pattern: http://example.com/category/*/index.php
    Exclude pattern: http://example.com/category/*/*/index.php
    Redirect to: http://example.com/category/cat/index.php
    Pattern type: Wildcard
    Example result: http://example.com/category/cat/index.php
  5. Redirect http to https using wildcards
    Example URL: http://mail.google.com/randomcharacters
    Include pattern: http://mail.google.com*
    Redirect to: https://mail.google.com$1
    Pattern type: Wildcard
    Example result: https://mail.google.com/randomcharacters

redirector-screen

GreaseMonkey Script:

We can also write greasemonkey script to handle this. Greasemonkey scripts are launched only on URLs matching the expreession you provide (so you can write sth like “http://dzone.com/*), and they are executed once page is loaded (top be more more detailed: when DOMContentLoaded event fires).

Writing a script should be easy with just plain JavaScript and XPath. You need to read some value by XPath like you say, and then to do the redirect, set window.location = ....

// ==UserScript==
// @name           Dzone Automatic Redirect
// @namespace      userscript_dzone
// @include        http://www.dzone.com/links/rss/*
// ==/UserScript==

   var XPathTools = 
   {
      getElementByXpath : function(xpath, referenceNode)
      {
         var xPathResult = document.evaluate (xpath, referenceNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
         return xPathResult.singleNodeValue;
      }
   };

   var xpath = "//div[@id='linkDetails']//div[@class='ldTitle']/a";
   var url = XPathTools.getElementByXpath(xpath,document);
   window.location = url;

Questions:

  1. Mozilla firefox add-on to redirect url from one domain name to another domain without changing the complete url
  2. Is there a Firefox Add-on for autmatic redirection?
Facebook Comments