我如何使seo友好的url这样,在后端我有节点服务器。Ango seo友好的网址和页面重新加载问题
http://localhost:3003/my-new-mobile //product
http://localhost:3003/my-new-category //category
http://localhost:3003/my-first-blog-post // blog post
我已经尝试过这样的东西,但它不工作。我将只使用一个控制器的所有4个以上的URL。 我可以使用正规快递吗?
$routeProvider
.when('^/([a-z])$', {
templateUrl: 'partials/main.html',
controller: 'MainCtrl'
})
当我试图像这样:
<html ng-app="myApp">
<base href="/client">
和app.js
$locationProvider.html5Mode(true);
它时重新加载页面显示错误。 http://localhost:3003/my-new-mobile
Cannot GET /my-new-mobile
任何建议,如何才能做到这一点或Cannot GET /my-new-mobile
错误如何避免?
这里是我的server.js
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.set('views', __dirname);
app.engine('html', require('ejs').renderFile);
var port = process.env.PORT || 3003;
app.listen(port, function(){
console.log('Listening on port ' + port);
});
app.get('/', function(req, res){
res.render('client/views/index.html');
})
app.get('/partials/:name', function (req, res) {
console.log(req.params.name);
res.render('client/views/partials/' + req.params.name);
});
app.use('/clientjs', express.static(__dirname + '/client/js'));
app.use('/bower_components', express.static(__dirname + '/bower_components'));
app.use('/images', express.static(__dirname+'/uploads/'));
服务器必须返回所有与index.html – YOU