RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
前后端分离用nodejs做seo
  1. 服务器(nodejs):
    a. 要点:
    前后端分离用nodejs做seo
    b. 完整代码:
    var http = require('http');
    var fs = require('fs');
    var url = require('url');
    http.createServer( function (request, response) {  
    var pathname = url.parse(request.url).pathname;
    console.log("Request for " + pathname + " received.");
    response.writeHead(200, {'Content-Type': 'text/html'});  
    fs.readFile('./head.html',function(e,head){      
      fs.readFile(pathname.substr(1), function (err, data) {
         fs.readFile('./foot.html',function(e,foot){
            console.log(head.toString())
            console.log(foot.toString())
            response.write("");   
            response.write("");   
            response.write("");   
            response.write("");   
            response.write("标题一");   
            response.write("");   
            response.write(data.toString());    
            response.write(foot.toString());        
            response.end();
         })
      });   
    })
    }).listen(3000);
    console.log('Server running at http://127.0.0.1:3000/');
  2. 前端html:
    a. head.html:
    
    
    
    
    标题
    

    b. index.html:

    创新互联咨询电话:18982081108,为您提供成都网站建设网页设计及定制高端网站建设服务,创新互联网页制作领域10余年,包括成都建筑动画等多个行业拥有丰富建站经验,选择创新互联,为企业保驾护航!

    
    

    身体

    这是一段文字

    c. foot.html:

    
    

网页标题:前后端分离用nodejs做seo
标题路径:http://sczitong.cn/article/iedphc.html