/Knowledge/sources/honojs__hono/llms-full/routing-routing-with-host-header-value--8c55b36e3db2.md
Routing: Routing with host Header value - hono-docs
Routing: Routing with host Header value Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt routing with h...
Routing: Routing with host Header value
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#routing-with-host-header-value
Summary
Hono can handle the host header value if you set the getPath() function in the Hono constructor. ```ts twoslash import { Hono } from 'hono' // ---cut--- const app = new Hono({ getPath: (req) => '/' + req.headers.get('host') + req.url...
Content
Hono can handle the host header value if you set the getPath() function in the Hono constructor.
import { Hono } from 'hono'
// ---cut---
const app = new Hono({
getPath: (req) =>
'/' +
req.headers.get('host') +
req.url.replace(/^https?:\/\/[^/]+(\/[^?]*).*/, '$1'),
})
app.get('/www1.example.com/hello', (c) => c.text('hello www1'))
// A following request will match the route:
// new Request('http://www1.example.com/hello', {
// headers: { host: 'www1.example.com' },
// })
By applying this, for example, you can change the routing by User-Agent header.
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#routing-with-host-header-value",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Routing > Routing with `host` Header value",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 602,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Routing: Routing with host Header value",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}