Adds ability to redirect from and to a specific protocol and/or host. It is now possible to use objects for the from and to properties in redirects.js.
If a from object is used (instead of the usual string or regular expression), the following properties are available:
protocol - If specified, the request's protocol must match for the whole redirect to match (http or https).
host - If specified, the request's host must match for the whole redirect to match (for example site.com).
path - The path to match, this is the same as the original from. Defaults to *, to match all paths.
If a to object is used (instead of the usual string or function), the following properties are available:
protocol - If specified, will override the request's protocol.
host - If specified, will override the request's host.
url - The url to redirect to, this is the same as the original to. Defaults to the request's url.
Example to automatically redirect to HTTPS and from the root domain to the www subdomain:
// redirects.js
exports = [
// http://site.com => https://www.site.com, will preserve the url
{
from: {
protocol: 'http',
host: 'site.com'
},
to: {
protocol: 'https',
host: 'www.site.com'
}
},
// http://www.site.com => https://www.site.com, will preserve the url
{
from: {
protocol: 'http',
host: 'www.site.com'
},
to: {
protocol: 'https'
}
}
];
Adds ability to redirect from and to a specific protocol and/or host. It is now possible to use objects for the
from
andto
properties inredirects.js
.If a
from
object is used (instead of the usual string or regular expression), the following properties are available:protocol
- If specified, the request's protocol must match for the whole redirect to match (http
orhttps
).host
- If specified, the request's host must match for the whole redirect to match (for examplesite.com
).path
- The path to match, this is the same as the originalfrom
. Defaults to*
, to match all paths.If a
to
object is used (instead of the usual string or function), the following properties are available:protocol
- If specified, will override the request's protocol.host
- If specified, will override the request's host.url
- The url to redirect to, this is the same as the originalto
. Defaults to the request's url.Example to automatically redirect to HTTPS and from the root domain to the
www
subdomain: