0

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 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.