the rule should be the other way around, something like this.
rules: {'(.*)(?!\.html|\.jpg|\.css)' : '$1.html'}
This will match anything that does not have ".html", ".jpg" or ".css" at the end and add html to the end. Make sure that you add all the extensions that you do not want to match (or a regular expression to match them).
This is how I implemented the grunt connect connection hook, which anyone is looking for it:
Command line:
npm install grunt-connect-rewrite
Include the grunt task in the grunt file:
grunt.loadNpmTasks('grunt-connect-rewrite');
Save Slice
var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;
Customize configuration
grunt.initConfig({ connect: { options: { port: 9000, hostname: 'localhost' base:'<%= yeoman.app %>', //make sure you have a base specified for this example }, rules: { '^/index_dev.html$': '/src/index.html', '^/js/(.*)$': '/src/js/$1', '^/css/(.*)$': '/public/css/$1' } } })
Add middleware to the above block of options:
options: { port: 9000, livereload: 35729, // change this to '0.0.0.0' to access the server from outside hostname: '*', debug: true, base:'<%= yeoman.app %>', middleware: function(connect, options){ if (!Array.isArray(options.base)) { options.base = [options.base]; } var middlewares = [rewriteRulesSnippet]; options.base.forEach(function(base) { // Serve static files. middlewares.push(connect.static(base)); }); return middlewares; } }
Add the task below:
grunt.registerTask('server', function (target) { grunt.task.run([ 'configureRewriteRules',