Redirector is a Firefox add-on that lets you create redirects for specific webpages, e.g. always redirect http://bing.com to http://google.com. It was originally done by request for someone on the Mozillazine forums. Include/excludepPatterns 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. It’s hosted at the Mozilla Add-ons website, where you can read more about how the addon works and download the latest version. Support requests can be posted here in the comments.
Official Redirector page | Download latest version | Version History | Source code
I got a problem. In my case i just want to add something to a URL.
The original URL is for example:
http://www.gametrailers.com/video/debut-teaser-blur/49490
What i want is:
http://www.gametrailers.com/video/debut-teaser-blur/49490?type=flv
What i tried:
Include pattern: http://www.gametrailers.com/video/*/*?
Redirect to: http://www.gametrailers.com/video/$1/$2?type=flv
Pattern Type: Wildcard
It seems to work, there is just one problem. The extension runs amok and adds constantly another ?type=flv all the time, which results in a pretty long url in just a few seconds.
I’m trying to find a way to add a simple line to the URL, but somehow the extension reacts kinda weird.
I want to following:
http://www.gametrailers.com/video/e3-09-rabbids-go/49701
to
http://www.gametrailers.com/video/e3-09-rabbids-go/49701?type=flv
So i just want to add a ?type=flv to the end of the URL.
I tried the following:
Include pattern: http://www.gametrailers.com/video/*/*
Redirect pattern: http://www.gametrailers.com/video/$1/$2?type=flv
Pattern Type: Wildcard
The funny thing is, the extension runs amok and adds constantly another ?type=flv which nearly crashes my firefox if i don’t close the tab. Where’s my error? Looks pretty ok to me.
Hello please help me also:
Links are produced like this one :
http://www.website.com/people/invite/y540j8e5
This “y540j8e5″ is generated everytime a new person joins the website. The whole link is there to invite this person to this website.
I want this link to be clicked automaticly everytime it appears at the website (respectively in the html-code)
How to do this ?
@Nekomancer
Add this exclude pattern: http://www.gametrailers.com/video/*/*?type=flv
If the url ends with ?type=flv, it won’t be redirected then.
It would be nice if the extension can detect infinite redirections and forbid such redirection rules from being created.
Hi
When creating regular expression rules, it would be more convenient if the pattern must match the whole url, so I don’t have to add a ^ before and a $ after the pattern every time.
And is it possible to redirect ttp:// and hxxp:// to http:// ?
Thanks for the 1.7 update!
When adding a regular expression redirection rule, it would be more convenient if the pattern must match the whole url, so I don’t have to add a ^ before and a $ after the pattern every time.
And is it possible to redirect ttp:// and hxxp:// to http:// ?
@Tom: I’m afraid that’s not possible. What Redirector does is only look at the url in the address bar, check if it matches a pattern and then redirect. It does not look at the html code of the page.
@hyk: It might be more convenient in some ways but would also force you to always come up with a pattern that matches the whole url. I don’t think I’ll add that feature.
As for redirecting from ttp:// and hxxp:// to http://, it does not work in the current version because it explicitly checks for only http and https. However, if you are brave and want to change it yourself you can edit the file components\redirector.js, find the lines:
if (contentLocation.scheme != “http” && contentLocation.scheme != “https”) {
return nsIContentPolicy.ACCEPT;
}
and remove them. Then try to add a pattern with another scheme and see if the redirection works. It might work, it might not, I’ve never tried it myself
Hi! Very great add-on you have written there. I have a personal project in development where I need to rewrite every http/https request the browser do on the internet like:
http://www.test.com -> https://* -> https://someaddress.com/$1
This work great for the main page but all request for pictures, javascript, etc objects associated with the main request are not rewritten…
Is it possible to enable this? How hard would this be? Maybe I can make the change to the code with the right directions.
Why do I want to do this? This is essentially a different (new) way of doing proxy I am working on. Instead of attempting to rewrite everything from the back-end point of view and fail I would rather get the browser to rewrite all url request on the fly as they are made.
Cheers
To clarify a bit what I attempting to do here is a simple example:
user want to get http://somesite.com
2. redirector change url to http://proxysite.com/somesite.com
3. proxysite.com fetch main page of somesite.com and return as is to user
4. Browser parse returned page and request 1st element as http://somesite.com/img/pica/jpg
5. redirector change url to http://proxysite.com/somesite.com/img/pica.jpg
6. etc, etc
Hope you can provide some help. i looked at the redrector.js and can’t figure how to make it act on all url requested ;-(
@bmaltais:
It might be possible to do that. The thing you wanna look at is the file components\redirector.js, specifically the shouldLoad function. That is what determines whether an url should be redirected. You can see that I check if the request is TYPE_DOCUMENT and only handle those, you might want to handle some other types. Look at http://www.oxymoronical.com/experiments/apidocs/interface/nsIContentPolicy for more about nsIContentPolicy. The problem with images is that the aContext you get is the DOM of the page, and the docs explicitly say that you should not mess with it at that point. I have tried it once though and it seemed to work, but be aware that you are in unsupported territory there.
The nsIContentPolicy has some problems for Redirector as well, 301 redirects do not go through it for example. A guy on the Mozilla suggested that one way to do redirection would be to implement your own http handler, but that seems to be a lot of work.
Anyway, if you get it working, please let me know, I would be interested in any alternative solution. Good luck
Hello,
FIREFOX 3.5.1 XP SP3
FRA=Redirector 1.7.1 crée une boucle sans fin et Firefox crash une fois que la mémoire est pleine ou je dois tuer le processus moi-même (Windows XP SP3 FRANÇAIS).
ENG=Redirector 1.7.1 creates an endless loop and Firefox crash when the memory is full or i must to kill the process myself (French Windows XP SP3).
FRA=Exemple de règle que j’utilise (et sans la règle d’exclusion il se créé une boucle sans fin) :
ENG= Example of a rule that i use (and without the exclusionary rule it created an endless loop):
about:config = extensions.redirector.redirects = ;http://www.google.fr/search?hl=fr&q=test&sourceid=navclient-ff&rlz=1B3GGGL_fr___FR291&ie=UTF-8,,,http://www.google.*/search?hl=*&q=*&sourceid=navclient-ff&*&ie=UTF-8,,,http://www.google.fr/search?q=$3,,,W,,,http://www.google.fr/search?q=*:::
FRA=Merci de fixer ce “petit” soucis.
ENG=Please fix this “little” problem.
FRA=Pouvez-vous ajouter un système de tri pour monter/descendre les règles s’il vous plaît ?
ENG=Can you add a sorting system for up/down rules please?
FRA=Merci beaucoup pour tout.
ENG=Thank you very much for everything.
Hi Einar,
please help me with this:
I would like to redirect all pages starting with “http://www.facebook.com/” to “http://hr-hr.facebook.com/”.
Sounds easy, but when I enter the rule, nothing happens (still goes to “http://www.facebook.com/”).
However, when I enter “http://hr-hr.facebook.com/” directly into browser it works well. Any ideas?
The system is Win Xp SP3, with Firefox 3.5.
Thanks in advance,
Juraj
Nobody?
Can anyone at least explain what does *,^, (), \, / mean when defining patterns?
Thanks in advance.
Juraj
Hi,
here is a info what I have got from Einar regarding my issue:
This should work:
Include pattern: http://www.facebook.com/*
Exclude pattern: http://hr-hr.facebook.com/*
Redirect to : http://hr-hr.facebook.com/$1
Pattern type: WILDCARD!
See if that works, and let me know if it doesn’t. You might also want to add another pattern that redirects facebook paths without the www, e.g. http://facebook.com/* to http://hr-hr.facebook.com/$1.
Having a problem with wildcards
http://($1)&url=http://($2) -> http://($2)
works most of the time. dont understand its random failures and
http://($1)&u=http://($2) -> http://($2)
doesnt seem to work at all
additional info:
http://($1)&url=http://($2) -> http://($2)
works for
http://www.someurl.com/st/st.php?id=558469&url=http://anything
But not for
http://www.someurl.com/dtr/link.php?link=image&gr=1&id=1204f3&url=http://anything
or
http://someurl.com/cgi-bin/a2/out.cgi?l=tmx5×545x135&s=39&u=http://anything
I’ve been trying various replacement combinations for the middle section but cant find one that works
Hi,
this add-on is a great thing, thank you for your work, but I have a bit suggestion:
It could be nice if the redirection rules attach the ‘inner links’ too, like the javascript, css, image …
Thanks
I know it is just meant to transform URL’s, but would it be possible to read the page (as was previously done for the ‘Only if link exists’ option) and transform a URL on the page.
e.g. On blah.blah.com/2009/09/18/article.html is a link with the text “Print” and URL javascript:printPage(84775); which when clicked opens blah.blah.com/print.html?id=84875.
What I am requesting is the ability to specify tranformation of the js link to the print link either by matching “javascript:printPage(*);” in the URL embedded in the CONTENT or by matching a link named “Print”.
I know this is not your ‘day job’ so I am not demanding anything.
Thanks for sharing
Dale
P.S. If you or anybody knows anything that does this, could you please reply and let me know. Cheers!
Hi Dale
I don’t want to change Redirector to a link rewriting extensions (which admittedely is quite similar, but still a different thing). But there might well be other extensions that do this.
What you might want to consider is to just make a redirect for the actual url that eventually gets opened after the javascript link is clicked. E.g. in your example you could use the pattern:
http://blah.blah.com/print.html?id=*
and redirect it to what you want. Or is the problem that you just want to be able to see what url the link will open, not actually change it to something else?
I downloaded Redirector for the purpose of fixing broken image paths in web sites (I was reading articles on a web site that changed there images path and didn’t fix the URL on old articles). However, like Tarquin, I found it will not replace the path in IMG tags. Any chance this feature will be added?
Nevemind, I found that FoxReplace will do what I need. You can replace any string in the source HTML with it.
Hi,
I’m having trouble with using this to redirect from OpenDNS’s search page. I have the following set up (these are the same settings as Kmaid’s):
http://guide.opendns.com/?url=nytimes
http://guide.opendns.com/\?url=(\w+)
http://google.com/search?btnI=1&q=$1
with regular expressions set. When I just type in, say, nytimes in the address bar, OpenDNS automatically redirects me to http://guide.opendns.com/?url=nytimes, and redirector does not take me to http://google.com/search?btnI=1&q=nytimes. But if I subsequently click on the location bar and press enter it redirects.
Thanks in advance, if this works browsing will be a lot more pleasant again.
Hi rb.
The problem you are having is because the page you are trying to redirect from is the result of a redirect from the webserver (a so called 301 or 302 redirect) and those are not checked against Firefox content policies, which is what Redirect is under the hood. Fortunately I have a workaround for this in the next version, Redirector 2.0. I have just finished working on that, but haven’t done the final round of testing. But if you are feeling brave and want to beta test it, you can download it at http://tech.einaregilsson.com/download/redirector-2.0-alpha-notsupported.xpi and see if that helps you. It also contains a number of new features, improved GUI, ability to re-order redirects, disable individual redirects, unescape matches, import and export redirects and other good stuff.
But, like the name implies, this pre-release is not officially supported, it may contain some bugs, and you should probably back up your redirects before trying it out, if you want to try it. (Backup by going to about:config, and copying the value of the key extensions.redirector.redirects to some text file).
If you (or anyone else reading this) downloads this pre-release and finds some bugs, please let me know. It will be uploaded to AMO tomorrow or Wednesday, but then it may take up to a few weeks to get it reviewed and officially released.
Hi,
I’ve tested the alpha version.
Everything worked well until today, I have this error message box when I restart my firefox:
Failed to initialize Redirector.
[Exception... "Cannot convert WrappedNative to function" nsresult: "0x8057000d (NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)" location: "JS frame :: chrome://redirector/content/code/browserOverlay.xul.js :: anonymous :: line 18" data: no]
Hi Peuj
Does it happen everytime? What version of Firefox are you using?
Yes since it happens, it happens everytimes.
Redirector always load enabled and I cannot disabled it.
As you didn’t answer, I’ve uninstalled it and reinstalled again because it was really annoying.
Now I don’t have the problem anymore.
It seems the problem happens after installing an new addon. But I’m really not sure it is the cause.
I googled the error code and most of what I found was something about conflicts with the prototype.js library. Do you remember what addons you installed after Redirector?
I’m pretty sure it is an addon conflict, otherwise it should happen always. Judging from the linenumber the problem might just be that I need to namespace my code better. Let me know if you find a way to reproduce the problem reliably (e.g. “it always happens after installing addon X”)
I’ll try to make some tests tonight.
The addon installed was SkipScreen https://addons.mozilla.org/en-US/firefox/addon/11243
Hi,
I confirm the problem happens after the installation of SkipScreen https://addons.mozilla.org/en-US/firefox/addon/11243
Confirmed the problem described by Peuj at 6 November.
Workarround:
Edit /chrome/content/code/browserOverlay.xul.js, and modify the following:
line 9: onLoad : function(event) {
to:
onLoad : function(event, Prefs) {
Line 105: window.addEventListener(”load”, function(event) { RedirectorOverlay.onLoad(event); }, false);
to:
var RedirectorPrefs = Prefs;
window.addEventListener(”load”, function(event) { RedirectorOverlay.onLoad(event, RedirectorPrefs); }, false);
Reporting another bug:
Icon not showing on *nix system, which is case-sensitive on filesystem.
Rename /chrome/skin/statusinactive.PNG to /chrome/skin/statusinactive.png (the same with status.png)
Edit /chrome/content/ui/browserOverlay.xul, and do the same with line 27:
<image id=”redirector-statusbar-img” src=”chrome://redirector/skin/statusactive.PNG”
to
<image id=”redirector-statusbar-img” src=”chrome://redirector/skin/statusactive.png”
@Lekensteyn: Thanks a lot for the detailed bug report. I’ll add these fixes to a bugfix patch I’m making. It’ll take a while for it to get to AMO but I’ll make it available here in the meantime.
Ok, done. While we wait for AMO to review the bugfix release it can be downloaded from http://tech.einaregilsson.com/download/redirector-2.0.1.xpi
Hey,
I got an error when loading firefox with this add-on :
—–
Failed to initialize Redirector.
[Exception... "Cannot convert WrappedNative to function" nsresult: "0x8057000d (NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN)" location: "JS frame :: chrome://redirector/content/code/browserOverlay.xul.js :: anonymous :: line 18" data: no]
—–
Any Solutions ?
Thanks !
@Neo: Yes, that bug has been fixed. It’s pending review at addons.mozilla.org but you can download it at http://tech.einaregilsson.com/download/redirector-2.0.1.xpi in the meantime
Thanks ! Indeed it seems to work better…
Redirector is great! Thanks!
Regarding bmaltais (above) and only checking if the request is TYPE_DOCUMENT (above)…
I’ve found that I can also check for TYPE_SCRIPT so long as I’m willing to REJECT_REQUEST only (with no redirect). With TYPE_SCRIPT, redirect is not possible as the loadURI() method is not available with this type (maybe there’s some other way?).
Still, I find that reject-only functionality with javascript is very useful, as I’m happy to simply reject things like this:
https?://.*\.google-analytics\.com/.*\.js
My diff can be seen here:
http://pastebin.com/f46e55056
@1258310340@noid.net: Interesting. I did look into redirecting other things a while back, but the lack of loadURI is the problem like you’ve seen. When you get a script what you get is typically an aContext that is the script DOM node itself. It is kinda sorta possible to just call .setAttribute() on it with a new url, but I found some pages on MDC that explicitly said that altering DOM nodes during load was something that was completely unsupported and had undefined results. So, I decided to skip that feature.
If you just want to block scripts you also might want to use the NoScript addon instead.
As for bmaltais thing about redirecting everything to https, I think maybe implementing a custom proxy might be the way to go there. I did it once for a old addon but don’t remember exactly how it was done, I don’t think it was too hard though.
I used Redirector for a while to get rid of Wikipedia’s “Click here to login” and “Click here to return to previous page” after logging in. The “Only if link exists” option is necessary to avoid loops in this situation, but was removed
Hi Martin. Sorry about that, but you’re the first person I remember to complain about the removal of ‘only if link exists’. Unfortunately it won’t be added again, as currently all redirects are performed before a page is loaded.
Thanks – I use your program to watch fx Comedy Central full episodes outside USA.
My pattern is this:
———–
http://www.thedailyshow.com/full-episodes/*/*
*the%20daily%20show*
http://media.mtvnservices.com/mgid:cms:item:comedycentral.com:$1
———–
It makes navigation at /full-episodes/ impossible, but I use the /video/ – and can now easily find and watch it all….
I load a html page and it includes an image with URL is for example :
http://imagehost/image.jpg
and I want to redirect this url to http://redirecthost/image.jpg
(for blocking this image for example)
is it impossible?
@tad: No, sorry, that is not possible. Image redirects are not supported. You might want to look at AdBlock if you just want to block the item.
Import/Export doesn’t seem to work on Macs running 10.5. (At least, Export doesn’t work, so I can’t generate an export file to test Import.) Tested on two different machines running Firefox 3.5.5; when you go to the export option and select your desired filename, it just takes you back to the import/export screen as if it succeeded, but no file is created.
@sweth: Hi, sorry for the late reply. I don’t have access to a Mac myself. Can you check after exporting whether there is any message in the Error Console?
Include pattern: http://*.google.com/*
Redirect pattern: http://anonymouse.org/cgi-bin/anon-www.cgi/http://$1.google.com/$2
Pattern Type: Wildcard
It’s not work.
Invalid Redirect detetcted:
The pattern “http://*.google.com/*” redirected the url http://www.google.com/ to http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.google.com/ which also matches the pattern. This will cause an endless loop and so the redirect has been disabled to prevent this from happening. You should edit this redirect to fix it.
@Eros: Try adding an exclude pattern, something like:
http://anonymouse.org*
Dear einar: Thank you so much, and it’s working now. Thank you for your direction.
Hi, I have a very simple/complex request…
Original link:
http://feeds.hwupgrade.it/c/32480/f/477553/s/82941fb/l/0L0Shwupgrade0Bit0Cnews0Cskvideo0Cle0Eprime0Esoluzioni0Envidia0Efermi0Ea0Emarzo0I311640Bhtml/story01.htm
Redirect link:
http://www.hwupgrade.it/news/skvideo/le-prime-soluzioni-nvidia-fermi-a-marzo_31164.html
I need to replace:
0E -> -
0c -> /
0I -> _
0B -> .
…
To match this (partial) 0Cnews0Cskvideo0Cle
I use this [0C[a-zA-Z0-9]*]* but there’s no way to use $x recursively.
Possible solution:
After the address recostruction (the actual usage) you can add an other option to replace occurrences:
a – Checkbox: active/deactive
b – Laberl: Replacer
c – TextField: (ori,dest);(ori,dest)…
0Cnews0Cskvideo0Cle
[0C[a-zA-Z0-9]*]* —-> match ok
Redirect to -> 0Cnews0Cskvideo0Cle
Replacer active (0C,/)
Final redirect -> /news/skvideo/le
Powerfull and simple.
If you implemtent this I thanks you very very much
Hi Rigel.
Sorry but I don’t think I will be implementing that feature anytime soon, since it is fairly specialized and the addon is a bit too technical already.
It is strange though that they use these chars and not % before them like normal escaping. If that was the case you could just use the “unescape matches” option. Can you give me an example of a page that has these links?
best regards,
Einar