basepath: add support for /jackett base path redirection

This commit is contained in:
kaso17 2018-01-23 20:40:37 +01:00
parent d578f585b3
commit 4fef4f872e
2 changed files with 5 additions and 5 deletions

View File

@ -77,12 +77,12 @@ namespace Jackett.Services
{
if (config.BasePathOverride == null || config.BasePathOverride == "")
{
return "/";
return "";
}
var path = config.BasePathOverride;
if (!path.EndsWith("/"))
if (path.EndsWith("/"))
{
path = path + "/";
path = path.TrimEnd('/');
}
if (!path.StartsWith("/"))
{

View File

@ -18,14 +18,14 @@ namespace Jackett.Utils
{
if (context.Request.Path != null && context.Request.Path.HasValue && context.Request.Path.Value.StartsWith(Engine.ServerConfig.RuntimeSettings.BasePath, StringComparison.Ordinal))
{
context.Request.Path = new PathString(context.Request.Path.Value.Substring(Engine.ServerConfig.RuntimeSettings.BasePath.Length - 1));
context.Request.Path = new PathString(context.Request.Path.Value.Substring(Engine.ServerConfig.RuntimeSettings.BasePath.Length));
}
if (context.Request.Path == null || string.IsNullOrWhiteSpace(context.Request.Path.ToString()) || context.Request.Path.ToString() == "/")
{
// 301 is the status code of permanent redirect
context.Response.StatusCode = 302;
var redir = Engine.ServerConfig.RuntimeSettings.BasePath + "UI/Dashboard";
var redir = Engine.ServerConfig.RuntimeSettings.BasePath + "/UI/Dashboard";
Engine.Logger.Info("redirecting to " + redir);
context.Response.Headers.Set("Location", redir);
}