I am developing website using BrowserSync. However, in the production version, I will be replacing .html with forward slash via .htaccess . Is it possible to achive the same result using BrowserSync?
1 Answer
You can start your browsersync with next server config:
server: {
baseDir: "./build",
serveStaticOptions: {
extensions: ['html']
},
middleware: function(req, res, next) {
var url = req.url;
if (url.length > 1 && url[url.length-1] === "/") {
req.url = url.slice(0, url.length - 1);
}
return next();
}
}
Not perfect solution, but if you go to http://foo/bar/ instead http://foo/bar.html it will not cause get error.