Ultra-minimalistic Node.js redirect server.
When you need a simple redirect server, to redirect subdomains, HTTP to HTTPS or even your own URL shortener.
The only thing you need to do is deploy this repository and add your redirects to redirects.json
file.
After deployed, all the HTTP requests will look for a registered request inside this file and will redirect using a standard HTTP redirect with Location
header and an optional status code.
{
host: "myhost.com",
path: "/mypath",
destination: "https://url.to/be/redirected,
status: 301
}
host
will match URL's hostname and port. i.e.https://google.com:123/search?q=term
host isgoogle.com:123
path
will match the entire path and query afterhost
. i.e.https://google.com:123/search?q=term
path is/search?q=term
destination
should be any valid URL. If not present, will be redirected todefaultDestination
.status
should be any valid HTTP status code. If not present, will be used code 302.
Apé will check request URL and look redirects
for:
- Both
host
andpath
of URL. - Only
host
of URL. - Only
path
of URL. - If not found a redirect rule, it will redirect to default configured destination in
redirects.json
file.
This repository is already configured for an Azure deployment. If you use this cloud, follow the steps below.
- Create an App Service.
- Click Deployment options and choose
External Git Repository
. - Put this repository clone URL and follow on.
- Await for deploy and access
https://yourappname.scm.azurewebsites.net/dev/wwwroot/redirects.json
to edit the redirects. - Et voilá!
This release was tested with Node 8.9.4. Some used JavaScript features, as
const
declaration and string interpolation may not work with older versions.To make sure your app will work with this release, change
WEBSITE_NODE_DEFAULT_VERSION
to8.9.4
in Application settings section.If you can't upgrade your Node version, consider using Babel to transpile apé's to an older ECMAScript version.
PLEASE. Make a pull request!
Apé is a word in Tupi-Guarani, a native south-american indian language, that means "the path".
- Full URL matching
- Regex URL matching
- Other cloud deploying configurations
- Variables to use with destination URLs