RedirectPlugin

Plugin for WebFramework that adds simple static redirects.

Changelog

Repository on GitHub

Main features

  • Creating static redirects as files

Installation

You can add this plugin to your WF project by installing the NuGet package: uwap.RedirectPlugin
You can also download the source code and reference it in your project file.

Once installed, add the following things to your program start code:

  • Add using uwap.WebFramework.Plugins; to the top, otherwise you have to prepend it to RedirectPlugin
  • Create a new object of the plugin: RedirectPlugin redirectPlugin = new();
  • Map the plugin to a path of your choosing (like any/r): PluginManager.Map("any/r", redirectPlugin);

You can do all that with a single line of code before starting the WF server:
PluginManager.Map("any/r", new uwap.WebFramework.Plugins.RedirectPlugin());

Usage

To create a redirect from [mapped path]/[redirect path] to [target], create a new file ../Redirects/[redirect path].txt (you can also create subfolders) and enter [target] as the content.

Currently, all instances of the project use the same folder for their redirects.

The redirects are stored in memory during runtime and updated by the worker.

Example: After mapping the plugin to uwap.org/r and creating a file ../Redirects/test.txt containing https://github.com/pmpwsk, visitors will be redirected from https://uwap.org/r/github to https://github.com/pmpwsk.

Plans for the future

  • Different redirect folders for different instances of the plugin in case there are multiple
  • Web interface to manage (create and delete) redirects with an API, either to manage the files or replacing the files altogether