Serve multiple redirects from a single text config file. Based on the _redirects
format from Netlify.
Built for net6.0
, net5.0
, netcoreapp3.1
.
- Local path to local path.
- Local path to remote URL.
- HTTP 301 Moved Permanently (default) or 302 Found.
Package from Nuget: https://www.nuget.org/packages/BulkRedirects
dotnet add package BulkRedirects
Add to application routing:
var builder = WebApplication.CreateBuilder(args);
// place where needed in the pipeline
app.UseBulkRedirects();
app.Run();
- Looks for
_redirects
file in the application content root by default, but custom path can be specified. - One redirect per line with format:
source
path,destination
path, and optionalstatus
code, all separated by spaces or tabs. - Blank lines and lines starting with
#
are ignored. - Note: Ensure that it's included in the build output.
Example file:
# comments and blank lines are allowed
/page1 /gohereinstead
/page2 /goheretemporarily 302
/remotepage https://github.com
0.4.0
- Renamed to
UseBulkRedirects
. - Custom file path and access checks.
0.3.0
- Added Source Link for debugging.
- Added logging statements on startup.
- Fixed trimming in redirect entires.
0.1.0
- Initial release.