Nicer URL for Application Express is something that has had a few options for an is discussed a lot.  Here's yet another option using nothing but the RESTful services inside the APEX Listener.


First is to setup up the workspace prefix in the Administration



Now that's it's enabled back to the RESTful setup screens to make a new Module.  I left the URI prefix empty to make the URL have 1 less path but you could put in anything and that will just have to be in the path.  I'll show an example at the end.


Now to create the actual URI template that will answer for the URIs.  The key things here are the bind variables APP and PAGE.  In a later post, I'll build from here on passing parameters which will need a different template.



Now the actual 7 lines of code which could obviously be condensed.  This needs to be a GET of PL/SQL type with Secure turned off.  Then all that happens is the APEX Listener splits the URI's application and page up already for us to rejoin them into an actual apex URI.  That needs to be an outbound bind to the Location header.  Then there needs to be an accompanying status for 3xx to tell the browser to go follow it.  





The end result is what you'd expect.  There's a TON more that can be done with this same basic concept.  For example, use the apex views such as apex_applications to perform some validation before the redirect then handle the 404s or other statuses directly,  looking up page items and setting those from a more robust URI template,  or even adding in vanity domain support with RESTful mappings. 


Here's the SQL Developer Exchange which is on apex.oracle.com as the example for this.






If anyone is interested, the animated GIF is from doing this:  https://gist.github.com/dergachev/4627207

The steps are pretty simple once ffmpeg and gifscale are installed via Mac Ports.  The only change I made was to set the delay to 15 instead of 5 in the example.