I have javascript that does different things depending on the URL. for this to work, I need to have consistent URIs.
for example, I need users to always be on www.site.com/users/bob/insteadwww.site.com/users/bob
node, unfortunately, does not support this, as it seems.
I tried redirecting with
router.get('/:user', function(req, res) {
res.redirect('/users/' + req.params.user' + '/');
});
but this just leads to a redirect cycle, as the URL with a slash and without a slash seems to be considered the same.
How can i do this? thanks!
Edit
I want to switch from WITHOUT a slash to Slash. the answers in another question are treated differently. I can not .substr (-1) my URLs
source
share