mirror of https://github.com/Jackett/Jackett
basepath: add support for /jackett base path redirection
This commit is contained in:
parent
d578f585b3
commit
4fef4f872e
|
@ -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("/"))
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue