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
}
hostwill match URL's hostname and port. i.e.https://google.com:123/search?q=termhost isgoogle.com:123pathwill match the entire path and query afterhost. i.e.https://google.com:123/search?q=termpath is/search?q=termdestinationshould be any valid URL. If not present, will be redirected todefaultDestination.statusshould be any valid HTTP status code. If not present, will be used code 302.
Apé will check request URL and look redirects for:
- Both
hostandpathof URL. - Only
hostof URL. - Only
pathof URL. - If not found a redirect rule, it will redirect to default configured destination in
redirects.jsonfile.
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.jsonto edit the redirects. - Et voilá!
This release was tested with Node 8.9.4. Some used JavaScript features, as
constdeclaration and string interpolation may not work with older versions.To make sure your app will work with this release, change
WEBSITE_NODE_DEFAULT_VERSIONto8.9.4in 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
