Friendly URLs for JS REST Resources


(Oleg Voronin) #1

Is it possible to set up page-level URL rewriting for assets in Squiz? Let's say we have a rest js resource that accepts GET properties like so:

example.com/REST_JS_ASSET?category=pets&subcategory=cats

What would it take to have a user-friendly URL

example.com/REST_JS_ASSET/pets/cats

render the same content as the original one? Naturally one restriction would be that the asset in question should have no children via organic urls.

 

I was looking into several workarounds, but none seem to be good enough: setting up custom webpaths - no support for dynamic options; redirect page - again doesn't work unless one is set up per option; and if an attempt is made to map a deeper path than squiz would 404. 

 

Even if there was no rewriting as such, but an option to use masks in webpaths (say, REST_JS_ASSET/*) then at least the URL could be parsed manually in JS REST Resource code by using a squiz global keyword...


(Nic Hubbard) #2

This isn't possible within Matrix itself, but this could in Apache I suspect as long as it was placed BEFORE the Matrix lines in your VirtualHost file.

 

This might help: http://stackoverflow.com/questions/9510774/friendly-url-to-accept-extra-params-in-the-traditional-way-phps-get


(Oleg Voronin) #3

This isn't possible within Matrix itself, but this could in Apache I suspect as long as it was placed BEFORE the Matrix lines in your VirtualHost file.

 

This might help: http://stackoverflow.com/questions/9510774/friendly-url-to-accept-extra-params-in-the-traditional-way-phps-get

 

I've briefly considered using an external (to Squiz) .htaccess file, but this would definitely be a challenge to maintain.