Trying to hide the word "index" from url like just example.com/ (or even better without the /) using nodejs and express. I got it to redirect on / and display the page on /index but wondering if I can remove /index and just show /, however the rendering only happens on /index not on /.
app.get('/', function (req, res) {
//called on / but just redirects url to /index I do not want to duplicate the rendering code here
res.redirect('/index') }); //to redirect / to index.html
}
app.get('/:slug', function(req, res){
//renders the page here but only called if /index in url not on /
}
UPDATE: Thanks I'm actually trying to make the :slug optional so the second statement somehow gets executed even on just / like :slug can't be empty it seems?