How about mod rewrite?
Opened this issue · 7 comments
In case I have a file called app/index.html to start the app,
given that I am using html5mode in angularjs,
how can I access the site directly using localhost:8000 instead of localhost:8000/app/index.html?
Please help and thanks!
I also consider the mod rewirte is useful.
I guess you may need this .
where in route.js
module.exports = {
"GET /**": "app/index.html"
}
then
puer -a ./route.js
Maybe today , I will update the puer to implement the simple static mod rewrite
It shows this when I use "GET /**": "app/index.html"
.get() requires callback functions but got a [object String]
@yhjor1212 because, it hasn't been implemented yet . :)
I push the commit to github right now , but haven't release it to npm. you can npm install it through github temporarily
npm install leeluolee/puer -g
the code
module.exports = {
"GET /**": "app/index.html"
}
will make the all path begin with '/' point to the app/index.html
file. which can make your angularjs app works on html5mode .
The error message indeed disappeared, but the reload still doesn't work:
access http://localhost:5000/pending1
get: Cannot GET /pending1
maybe you should show your configuration , so I can track the issue easily . @yhjor1212
-
Start server
puer -p 5000 -a scripts/route.js -
Application root
app/index.html -
Angular js route settings
angular.module('myApp.routes', ['ui.router'])
.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise("/home");$stateProvider
.state('home', {
url: "/home",
templateUrl: "app/partials/home.html",
controller: 'HomeCtrl'
})
...
$locationProvider.html5Mode(true);
- scripts/route.js
module.exports = {
"GET /**": "app/index.html"
}