19
loading...
This website collects cookies to deliver better user experience
next.config.js
.redirects
property accepts an async function, that returns an array of redirects./ie_warning.html
(which is a file served from the public
folder), and is set to be non-permanent, meaning that the server will return a 302
HTTP status code. If permanent
is set to true
, a 301
code is returned instead.module.exports = {
redirects: async () => {
return [
{
source: '/',
permanent: false,
destination: '/ie_warning.html',
},
]
},
}
User-Agent
. All IE11 user-agents contain the word Trident in their user-agent, so we can simply use a regex-like string to check if the header contains that word.module.exports = {
redirects: async () => {
return [
{
source: '/',
has: [
{
type: 'header',
key: 'User-Agent',
value: '(.*Trident.*)',
},
],
permanent: false,
destination: '/ie_warning.html',
},
]
},
}
module.exports = {
redirects: async () => {
return [
{
source: '/:path((?!ie11_warning.html$).*)',
has: [
{
type: 'header',
key: 'user-agent',
value: '(.*Trident.*)',
},
],
permanent: false,
destination: '/ie11_warning.html',
},
]
},
}
/ie_warning.html
. The exception is required to prevent a redirect loop.