Browser-sync: Is it possible to have vanity URLs? ie: remove .html extension?

Created on 11 Apr 2016  路  10Comments  路  Source: BrowserSync/browser-sync

Issue details

I'm just curious to know if its possible to serve .html files without the .html file extension at the end just for vanity purposes if its not possible that okay.

Thanks for making such a great tool for devs everywhere. Kudos!

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.11.2 ]
  • Node [ 5.7.1 ]
  • Npm [ 3.6.0 ]

    Browsersync use-case

  • [ ] API

  • [X ] Gulp
  • [ ] Grunt
  • [ ] CLI

Most helpful comment

sure

var bs = require("./").create();

// Start the server
bs.init({
    server: {
        baseDir: "./app",
        serveStaticOptions: {
            extensions: ['html']
        }
    }
});

All 10 comments

sure

var bs = require("./").create();

// Start the server
bs.init({
    server: {
        baseDir: "./app",
        serveStaticOptions: {
            extensions: ['html']
        }
    }
});

captura de pantalla 2016-06-07 a las 11 07 02 a m

Holy crap that worked! Thanks maybe serveStaticOptions should be on the docs 馃榿

Wow, that worked on my Foundation project! I had been fighting how to get pretty URLs to work on development environment (I'm more designer than developer), and this did it鈥攖hanks! :)

I'm also not able to get this to work, using the latest version of Browsersync, 2.16.0

@arloduff share your gulp file or bs.config.js file

I've just ran it no problem with both on the latest version ;)

This is my bs-config.js

module.exports = {
  "port": 8000,
  "server": {
    "baseDir": "dist",
    "index": "dist/my-app/index.html",
    "serveStaticOptions": {
      "extensions": [
            "html",
            "js"
      ]  
    }
  },
  "startPath": "/my-app"
};

It seems to be picking up the .html but if I try to make a request for a js file it doesn't recognize it without the extension.

i don't think ANY server would do that lol

I thought that was the point of this feature. Is it only supposed to pick up html files?

you should try it, but im guessing it should be limited to php and html files

Seems it should have been

extensions: "html,js"
Was this page helpful?
0 / 5 - 0 ratings