Confluence has already a feature built-in that is similar. This produces links like (in your case) http://wiki/x/ZgAJ. It is located at (Page) Tools -> Info.
If you want to have it even shorter you would have to implement your own Servlet Filter Module (https://developer.atlassian.com/display/PLUGINFRAMEWORK/Servlet+Filter+Plugin+Module).
Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events