i have angular site hosted in s3, , have 404 route set (i use hash), if example does
mysite/#/gibberish goes to
mysite/#/404 and on s3 bucket have redirect rule in place for
mysite/gibberish goes to
mysite/404.html all well
now want add logic on top if types in
mysite/customerid
which 404 somehow redirect angular controller can send request right page.
so somehow in redirect in s3 rule add reg exp incoming request , rather serve 404.html send i.e. mysite/#/handlethis
is possible ?
depending on router of choice, following (which we've done (well, not precisely this, close)):
ui-router
app.config(function ($urlrouterprovider) { var regx = /\/#\//; // match against /#/ $urlrouterprovider.otherwise(function ($state, $location) { if (!regx.test($location.path()) { // if no match $state.go('customhandlingstate', /** params **/, /** configuration **/ }); // transition custom handler state, optional params/config. } }); }); you pair custom statechange[start|stop|error|success] handlers in run block of app customise liking.
i supply example of how ngroute, gave on ngroute 2 years ago , haven't looked since. such have no suggestion give, nor able find solution problem present.
i strongly suggest scrap s3 portion of recipe make life lot easier when comes client side routing (speaking personal experience here, it's opinion on matter - not fact) , handle 404's/500's on client custom state handlers.
if need hook logging service , store data whenever client/person ends in erroneous state.
i suppose 'counter question' is; you gain using s3 redirect rules? better understanding needs , goals here.
some reference material go along:
Comments
Post a Comment