Introducing my latest WordPress plugin: GoCodes, the redirection plugin for WordPress.
Have you ever had to give someone a shortened version of a URL? Maybe you’re a podcaster, and you need to say “visit mydomain.com/2008/01/03/my-post-with-a-long-url/ for more info.” Wouldn’t it be useful if you could just say “go to mydomain.com/go/mycoolpost/ ?” Sure, you could use a service like tinyurl.com, but that’s still not too great if you need the URL for a podcast. It’s still awkward to read-out “tinyurl.com/27asr9,” isn’t it? It’s less professional too. GoCodes let’s you create shortcut URLs to anywhere on the internet, right from your WordPress Admin. Whether you need it for podcasting, printed publications, or affiliate programs, GoCodes will do the job for you.
You can read more and download the plugin here.

Is there a way to change the /go/ to something else or even hav the feature to have more than just the /go/ for different things? (Email me if you have to.)
Thanks
Mark
It is possible to change the /go/ to something else. In the lines of code you add to your .htaccess file there is a spot,
, where you can replace the word “go.”RewriteRule ^go/([A-Za-z0-9]+)
It is also possible to have multiples. By duplicating the line, and changing the “go,” you can have
RewriteRule ^go/([A-Za-z0-9]+)/?$ /index.php?gocode=$1 [L,R]
RewriteRule ^jump/([A-Za-z0-9]+)/?$ /index.php?gocode=$1 [L,R]
If you do that, then yourdomain.com/go/mypost1/ and yourdomain.com/jump/mypost1/ would point to the same place.
Hi matt, great site you run here, and a great plugin too.
I have installed and set your plugins, but can’t redirect it properly.
To test your plugin, I have to added this “recommend” Key to redirect to http://www.jawapos.com.
So if i type “www.henbima.com/go/recommend” it suppose to redirect to http://www.jawapos.com right? insead i got “http://www.henbima.com/?gocode=Recommend”, which point back to my site.
Would you care to point out what i might miss here?
thanks Matt!
Henbima, this issue seems to affect more than just you. I’m currently working with an other blogger who has the same problem. Once it is resolved, I will email you with the solution.
Great matt!! Will be waiting for your solution.
Btw, just FYI i found another plugin also function like your here, called “hidden affiliate links”. But theirs a bit complicated, that’s why i prefer using yours.
Glad you prefer my plugin.
I just uploaded GoCodes 1.1.1 to the WordPress Plugins Directory. I fixed a couple of bugs that seemed to be stopping the redirect on some servers. Just upload the new gocodes.php to your plugins folder and it should work correctly.
http://wordpress.org/extend/plugins/gocodes/
thanks Matt! it work great now.
I have just made a review about your plugin on my blog, as my thank you
Thanks for the review of GoCodes, Henbima.
Hi! And thanks for a great plugin. However, I can’t get mine to work. Oh no!
I installed as directed but landed in trouble when trying to add the code to the .htaccess file. I can’t find where it says: # BEGIN WordPress”.
Please help!!
Many thanks,
HypnoGirl
@HypnoGirl: You seem to be using the “semi-pretty permalinks.” The plugin isn’t entirely compatible with them. If you email a copy of your .htaccess file to me (see About/Contact page), I may be able to provide further assistance.
Wow, how wonderful! Thank you Matt. Sending to you now!!!
Hi Matt, thanks for the plugin. This is the exactly plugin that I am looking for. I like it. Perhaps, I missed some here. Could you help me to verify?
First, I have uploaded gocode.php into /plugin directory and activated it (version 1.1.1)
Second, I have uploaded .htaccess file in root with following entries.
RewriteEngine On
RewriteRule ^go/([A-Za-z0-9]+)/?$ /index.php?gocode=$1 [L,R]
Third, I have created a keyword named “test” and point to wordpress.org.
Fourth, I opened a browser and hit http://www.mydomain.com/go/test, it failed to redirect. It gave me page not found result (404)
Anything that I missed?
Thanks Matt.
@Sugeng A few other people have asked me about this, and I haven’t been able to find out what’s wrong. I think it has to do with the .htaccess somehow, but it only happens on some servers. I’ll ask about this on WordPress.org, and a few other forums if necessary, and let you know what I find out (I’ll send an email). But I have one question first:
What URL to you end-up on when the 404 error comes-up? Is it yourdomain.com/index.php?gocode=test ?
Hi Matt,
Thanks for your prompt reply. I have a good news for you.
The redirection is working now and I have done nothing to it. I use shared hosting so I have no idea why it can work now. Perhaps, there is a background processing that I am not aware of.
Please let me know if you know the answer. I am keen to know the reason of it.
Thanks again Matt, great work.
If you open for my suggestion, there are 2 features that I missed.
First is the “edit” feature. At this moment, I have to delete and recreate the link if I want to modify the link.
Second, “reset counter” also a nice to have feature to reset the hit counter.
Cheers
Thanks for your feature suggestions. I will consider implementing them in a future release.
I wonder why it started working all of a sudden like that… I will go ahead and post a query on the WordPress forum. I’ll let you know If I find anything out.
Matt, Is there a way to put a dash between keywords, such as /go/make-money so its not /go/makemoney , I would like to be able to have dashes between my keywords if possible. Thanks in advance for the answer.Jason
Curently, there is no support for dashes, any non alphanumeric characters. I can work on an update though. It may take a few days, but I’ll see what I can do.
It was just so much easier to only support alphanumeric at first.
Glad you created this plugin – Thank You! I did write a review about it, but since it is in Polish I don’t think it will be of any use to you
Keep up the good work
If you use this plugin for redirecting and hiding affiliate links, does this method retain the cookies needed for the affiliate to track?
@Susa, Yes it does.
One of the reasons I made GoCodes was for affiliate URLs.
Thanks Matt – I got a question regarding special handling of CJ affiliate links.See below (I also included the referenced url). I tried adding “&afsrc=1″ but the plugin omits the “&” when saved. is there a way to keep it included if this ‘&afsrc” set is needed for CJ? I’ve heard it’s also needed for BeFree and Performics when ‘hiding links’.————————————————–http://www.cj.com/code_of_conduct.html Publisher Link - an affiliate service
provider’s URL that is used to track end-user referrals from the
publisher Web site to the advertiser’s Web site, via the service
provider’s Web site or that contains a parameter named ‘afsrc’ set to
any value.
e.g. http://www.mysite.com/redirect.....38;afsrc=1
This ‘afsrc’ parameter option is provided to address the case where
affiliates modify or mask the links provided to them from the service
provider such that it is impossible to determine that they are
affiliate links solely based on the URL’s appearance. Publishers are
encouraged to contact technology providers for an updated list of
tracking domains.
@Susan, That’s odd. I don’t think I’ve seen anyone have that issue before… I can have &s in my URLs fine. Could you post a few screenshots (just host it somewhere like ImageShack.us or TinyPic.com and post a link here)? I’d like to see the affiliate URL starting out, how you have the form filled, and the final listing on the GoCodes management page. It would help toubleshooting a lot if I had a visual representation. (If you’re not comfortable posting screen caps here, you can send me an email at matt at [this domain]).
Matt, I’ve installed the plugin (vers 1.2.2) in WordPress 2.6 and added the redirect lines to .htaccess, but when I try to add a link in the plugin window I get the error: “cannot load gocodes.php” Any ideas? gocodes.php is in the plugin directory with 644 permissions. Thanks, Mark
Forget that issue – I found I had the gocodes.php in the plugins directory, but all by itself – not in the gocodes folder. Works now.
Hi! Great plugin. Works well. My only question is: is there a way to make the URL bar show “[my website]/go/[link name]” instead of the link once it redirects? Thank you,-Erica
@Ericabiz, no it can’t do that. Something like that would require the use of frames, of which there is no support for, and the use of which I generally disapprove of. Sorry. I hope this isn’t a major deal-breaker for you.
hi matt, I have a problem like sugeng …
First, I have uploaded gocode.php into /plugin directory and activated it (version 1.2.6)
Second, I have uploaded .htaccess file in root with following entries.
RewriteEngine On
RewriteRule ^go/([a-zA-Z0-9._-]*)/?$ /index.php?gocode=$1 [L,R]
Third, I have created a keyword named “test” and point to wordpress.org.
Fourth, I opened a browser and hit http://www.mydomain.com/go/test, it failed to redirect. It gave me page not found result (404)
Any idea what’s wrong ? I can’t move to other hosting, I have paid yearly for this hosting, please help … thank you.
hi Matt, sorry for the question, I can make it work now, I just have to read it carefully about .htaccess, instead of putting the rule above the “# BEGIN WordPress”, I put it inside it.
It works fine now …
This is a great plugin for managing links. As previous posters have pointed i also encountered a problem with the plugin working one time and not another. Somehow I have yet to figure out why, the .htaccess file changes itself or by another plugin and the necessary rewrite rule
RewriteRule ^go/([a-zA-Z0-9._-]*)/?$ /index.php?gocode=$1 [L,R]
get deleted from the .htaccess file
anyways thanks a ton for this plugin
Make sure the lines supplied in the readme file go *above* the #WordPress line in the .htaccess.
ok gotcha, thanks
Hi, I have almost got Gocodes to work properly. However, the resulting URLs drop the .com
For example, I get URLs that are http://domainname/go/keyword rahter than http://domainname.com/go/keyword
Any ideas what I am doing wrong. I am on WordPress 2.7 and I downloaded the latest Gocodes version from the WP plugin repository.
Thanks,
Barb
Nevermind. It is late and has been a long day. I found that I had made a mistake in wp-o-matic. Gocodes is working fine. Sweet. Thanks and good night!
Gocodes is not working properly for some of my keywords. For example, I got html code keyword showing in my post. Is there a way to fix this?
Heya Matt
Do you still respond to support issues for this plugin? You haven’t posted a response here since August last year.
I’ve followed the instructions in the readme.txt file, but still can’t get this plugin to work, I’m afraid.
The site is WP2.7-powered.
When I add a redirect in the GoCodes screen under Tools, I get a “Redirect successfully added” message, but nothing then appears in the bottom half of the page (under “Manage GoCodes”).
Any ideas?
Thanks very much. More than happy to make a donation for this cool little plugin if I can get it to work.
Best,
TheNightOwl
P.S. If I add the Rewrite rules with the ‘ then I get an internal server error. If I remove the ‘ then I can load the site. Don’t know if that offers any clues or not.
You don't want the quote-marks around the .htaccess rule. They just designate a block of code on WordPress.org's repository.
I do try to respond to support issues, but I don't develop the plugin as actively as I used to. I make some small tweaks here and there, such as to fix it for WP 2.7, but I haven't done anything major in quite some time. I do have a list of changes to make sometime when I have the time…
Have you tried deleting the plugin files and re-uploading them?
Heya Matt
Wow! What a SUPER-fast response!
Thanks. I did what you suggested (i.e. deactivated it, deleted file, re-FTPed, reactivated) and it worked a treat.
Thank you for such a cool little tracking utility! (You're now in the mownay to the tune of one brewski, sir. Enjoy!)
Best,
TheNightOwl
Enjoy the plugin, and let me know if you have any other problems.
P.S. I was clearly wrong about your last post being in August, too. I obviously wasn't paying attention to the new username versus avatar. My bad.
Thanks again.
I moved the comments over to IntenseDebate at one point, so I'm "redwall_hp" now instead of "Matt."
Hi Matt,
I have an asterisk in my affiliate URL. It seems that the asterisk is dropped during the redirect. Any solution to this?
What version of GoCodes are you running? The asterisk isn't a very common character in URLs, so it ends up being stripped-out. In the current 1.3.x line you want to look in menus.php (older versions have the line in gocodes.php). Find this:
$gckey = ereg_replace("[^a-zA-Z0-9._-]", "", $gckey );
And change it to
$gckey = ereg_replace("[^a-zA-Z0-9._-*]", "", $gckey );
If you're using .htaccess, which is required in versions prior to 1.3.0, you'll have to edit it from
RewriteRule ^go/([a-zA-Z0-9._-]*)/?$ /index.php?gocode=$1 [L,R]
to
RewriteRule ^go/([a-zA-Z0-9._-*]*)/?$ /index.php?gocode=$1 [L,R]
Sorry if you got confused. My problem is in the redirection itself. The asterisk is saved in the database, though during the redirect process, it is dropped. I think the issue is in the gocodes.php
$gocode_db = $wpdb->get_row("SELECT id, target, key1, docount FROM $table_name WHERE key1 = '$gocode_key'", OBJECT);
$gocode_target = $gocode_db->target; // << – Not sure if the * is dropped here
It's probably the .htaccess doing it… If you edit the RewriteRule line that I suggested above, it might fix it.
.htaccess is the first stage of the redirect process (or it was until the 1.3.x version). If you're using 1.2.7 or prior, I would guess that .htaccess is stripping it out because the RewriteRule doesn't account for it. (It assumes that the URL only contains alphanumeric characters, undersores, and hyphes.)
Wow. that was fast
I found the culprit. It's in the wp_sanitize_redirect function in pluggable.php under wp-includes
change this line:
$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%]|i', '', $location);
to:
$location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%*]|i', '', $location);
Well that makes sense. Though if you're editing core files, remember that you'll have to re-edit them next time you upgrade WordPress.
Hi
I am trying to use Gocodes with the Mandigo theme. I have version 1.3.3.
However it seems to throw out the CSS in the Mandigo theme which ruins the layout.
Any ideas why?
That's…odd. Can you send me a live link through my contact form? http://www.webmaster-source.com/about/
Hallo Matt,
I am using gocodes plugin on one of my other site. Every thing in gocodes seems to work fine, But the problem occurs on my clicks tracking system.
e.g. I am promoting merchant site merchant.com through an affiliate network affnetwork.com. My affiliate network affnetwork.com gives me a generated link for promoting the merchant merchant.com like —-> merchant.affnetwork.com/my ID here.
This link is clearly showing that the clicks of the visitors are going through my AFFILIATE network server affnetwork.com, so that they can be tracked. If the links are not masked with gocodes, I can see all number of clicks (every time when a link is clicked the software counts that click) in the control panel of my AFFILIATE network affnetwork.com. And on the merchant site merchant.com itself you can see the visitor is redirected through that network, It will show something like this –> (merchant.com?network=name of network). Also, displayed URL in the visitors browser will be merchant.com?network=affnetwork
Now the problem comes when I mask the links with gocodes. They don’t get counted on my affnetwork.com control panel, why I don’t know.
But the visitors browser still shows that he came through affnetwork, as in the URL bar ( ?network=affnetwork ) still can be seen!!!
Now I don’t know whats going on? Is the gocodes plugin changin the urls? Is this a problem of my affiliate network? Can I see the redirected links any how? I don’t know what I should do. Will be thankful for any help. And thanks for developing such a good plugin for the community.
Devin.
GoCodes does not change the URLs in any way. It simply forwards one to the other.
My only guesses are
1. The affiliate network is using some sort of server-side magic on their end to count the clicks.
2. Is there some extra bit, such as a JavaScript snippet, that the network provides that you used without GoCodes?
Hallo Matt,
Thanks for the fast reply.
TO 1:- It is possible that they are using some software to count the redirected links through there server (may be thats why I can see the counted clicks in my Control panel).
TO 2:- No! Affiliate Network just generate links to the Landing pages for the Merchant site, and that is all. They don’t provide any thing else than the normal Links with my publisher ID.
What do you say (from past expirience and as a developer of GoCodes plugin), If a visitor is redirected to the right page on my merchant through my affiliate network, will I get the credits for the made sale (even if my affiliate network didn’t counted that link). Do you think on my MERCHANT site the refferer (link with my ID) is listed properly in their logs or there could be some problem.
I am little new to all this stuff, that’s why asking for some expirienced persons help.
Thanks, Devin
I'm not sure, it depends on how the affiliate server is set up. Is there any chance you could talk to the affiliate site and ask about the issue? If you can, you should ask if a basic HTTP 301 redirect would break their tracking system.