REDIRECTOR HELP
Table of contents
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.
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.
Basic usage
To add a new redirect you press the Redirector icon next to your address bar, and in the popup that comes up you choose the Edit Redirects button.
On the settings page you can add, edit and delete redirect. Redirects will be checked in the same order as they are shown on that page, so you can move them
up or down to give them higher or lower priority. The edit form will guide you by showing you an example result as you're typing in your patterns. A redirect
contains the following fields:
- Description: The description is optional, it's only there for you to better keep track of your redirects
and why they're there.
- Example url: This is an example of an url you want to redirect. It is used to help you create your redirect, and show you
an example result while you're editing the redirect.
- Include pattern: This is pattern for the urls you want to redirect. In the simplest case, where you just want
to redirect one specific url to another then this will just be the exact url you want to redirect. For instance, if you just want http://aaa.com to
redirect to http://bbb.com then Include pattern will just be http://aaa.com. For more complex patterns that match many
urls you can use either wildcards or regular expressions.
- Exclude pattern: Urls that match this pattern will never be redirected. This is not necessary to
fill out, but can be useful when you want to redirect all urls that contain some text except if they contain some other text.
Redirects like that can often be done with a complex regular expression, but using an exclude pattern makes it much simpler. The exclude
patterns can use wildcard characters or regular expressions like the include patterns.
- Redirect to: This is the url that you will be redirected to when you open any page where the url matches the
include pattern. You can use the special signs $1, $2, $3 etc. in the url, they will be replaced by the results of captures with regular
expressions or stars with wildcards. For instance, if you have the include pattern http://google.com/*, redirect to http://froogle.com/$1
and you open the page http://google.com/foobar, then you will be redirected to http://froogle.com/foobar, since 'foobar' was what the star replaced. $1 is for the
first star in the pattern, $2 for the second and so on. For regular expression $1 is for the first parentheses, $2 for the second etc.
- Pattern type: This specifies how Redirector should interpret the patterns, either as
wildcards or regular expressions.
- Process Matches: In some cases parameters in urls are encoded in different ways. The Process Matches option allows you to select a few
different ways to process the Regular expression matches before using them. The decoding options available are:
- No Processing: This is the default. Just use the matches from the original url exactly as they are.
- URL Decode matches: A common usage of Redirector is to catch urls like
http://foo.com/redirect.php?url=http%3A%2F%2Fbar%2Ecom%2Fpath and try to catch the url parameter and redirect to it. A pattern
like http://foo.com/redirect.php?url=* might be used for that purpose. However, if the url parameter is escaped (also known
as urlencoded) then that won't work. In the url above we see that it starts with http%3A%2F%2F instead of http://, and Firefox
won't accept this as a new url to redirect to. So, in cases like these you can select the URL Decode matches option and then all
matches will be URL decoded (turned from e.g. http%3A%2F%2Fbar%2Ecom to http://bar.com) before being inserted into the target url.
- Double URL Decode matches: Same as above except apply the decode function twice, if the url has been encoded twice.
- URL Encode matches: The opposite of URL Decode matches. Let's say you want to redirect all requests to
a domain like http://example.com to some proxy site that took the url to proxy as an url parameter. Then you might do something like the regular expression pattern
^(http://example\.com/.*) and redirect it to http://proxysite.com?url=$1. If you used the Escape matches option then the
final url would become http://proxysite.com?url=http%3A%2F%2Fexample.com%2Ffoo%2Fbar.
- Base64 Decode matches: Similar to URL Decoding, in some cases a parameter in a url might be Base64 encoded. This option will decode that parameter before using it in the target url.
- Apply to: The Apply to option is new in version 3.0 of Redirector. For 99% of cases you won't need this, so don't worry about it.
By default Redirector only redirects requests from the address bar of your browser, the page you're viewing. It doesn't redirect requests for scripts, iframes, images
or anything else. Now in version 3.0 it is possible to opt into that however, and redirect any type of request. Just beware that this might have performance implications
if you're redirecting all types of requests and you have many redirects.
Wildcards
Wildcards are the simplest way to specify include and exclude patterns. When you create a wildcard pattern there
is just one special character, the asterisk *. An asterisk in your pattern will match zero or more characters and you can
have more than one star in your pattern. Some examples:
- http://example.com/* matches http://example.com/, http://example.com/foo, http://example.com/bar and all other urls that start with http://example.com/.
- http://*.example.com matches all subdomains of example.com, like http://www.example.com, http://mail.example.com.
- http*://example.com matches both http://example.com and https://example.com.
- http://example.com/index.asp* matches http://example.com/index.asp, http://example.com/index.asp?a=b&c=d.
$1, $2, $3 in the redirect urls will match the text that the stars matched. Examples:
- http://example.com/* matches http://example.com/foobar, $1 is foobar.
- http://*.example.com/* matches http://www.example.com/foobar, $1 is www, $2 is foobar.
Regular expressions
Regular expressions allow for more complicated patterns but they are a lot harder to learn than wildcards. I'm not gonna
create a regex tutorial here but normal javascript regex syntax works, look at Regular-Expressions.info for
an introduction to regular expressions. $1,$2 etc. can be used in the redirect url and will be replaced with contents of captures in
the regular expressions. Captures are specified with parentheses. Example: http://example.com/index.asp\?id=(\d+) will match the url
http://example.com/index.asp?id=12345 and $1 will be replaced by 12345. (A common mistake in regex patterns is to forget to escape
the ? sign in the querystring of the url. ? is a special character in regular expressions so if you want to match an url with a querystring
you should escape it as \?). To test your regular expressions, you may use any website or service. For example, RegExr.
Storage Area (Sync vs Local)
Storage Area, by default, is set to Local. If you wish to sync your redirector rules across devices, you may choose to enable Sync from Settings page.
When you toggle to Sync, data will be copied over to Sync storage and local storage will be deleted.
Similary, sync storage will be deleted if you disable sync and data will be moved to Local storage.
Note: - Google Chrome Sync and Mozilla Firefox Sync limits the storage size as per below.
This limit is decided by browser vendors and Redirector addon cannot do anything about changing the below.
- You need to use chrome/firefox settings to setup a sync account for syncing to work.
If that is not completed, Sync will just act like local storage - take note of the storage sizes below.
If sync account is not setup in chrome/firefox browser settings, leave the storage area to LOCAL as it has much larger size than Sync storage size.
- Local Storage: 5 MB - Redirector uses this as Default upon its installation
- Sync Storage : 0.008192 MB to store "Redirects" (8192 bytes)
Examples
-
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 |
-
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 |
-
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 |
-
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 |
-
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 |