title: /etc/hosts or express redirect not working for www version of the domain
body: <p>I would like to redirect all urls for domain using the hosts file and local web server. This works for domain.com but isn't working for www.domain.com. The logs from express server only show domain.com. Weirdly it works for wget (index.html downloaded from www.domain.com is correct), and on Firefox I get "unable to connect", on Chrome "this site can't be reached"</p>
  
  <p>/etc/hosts</p>
  
  <pre class="lang-sh prettyprint-override"><code>127.0.0.1    theguardian.com # tried removing this
  127.0.0.1    www.theguardian.com
  </code></pre>
  
  <p>index.js</p>
  
  <pre class="lang-js prettyprint-override"><code>const express = require('express')
  const http = express()
  http.get('/*', function(req, res) {
      const redirect =  req.headers.host + req.url
      console.log(redirect)
      res.writeHead(301, {Location: 'https://example.com/' + redirect})
      res.end()
  })
  
  http.listen(80)  // also tried 8080
  </code></pre>
  
  <p>I don't know how to troubleshoot this, only tried restart for now. When I get an error from the browser, the request doesn't show up in logs</p>