private static RewriteOptions AddRedirectorRoles(this RewriteOptions RewriteOptions, RedirectorOptions options)
        {
            var statusCode = options.RedirectStatusCode;

            if (options.ForceHttps)
            {
                RewriteOptions.AddRedirectToHttps();
            }

            if (options.ForceLowercaseUrls || options.TrailingSlash != TrailingSlashAction.NoAction)
            {
                RewriteOptions.AddCanonicalUrl(statusCode, options.ForceLowercaseUrls, options.TrailingSlash);
            }

            switch (options.WwwMode)
            {
            case WwwModeAction.NoAction:
                break;

            case WwwModeAction.ForceToWww:
                RewriteOptions.AddRedirectToWww(statusCode);
                break;

            case WwwModeAction.ForceToNonWww:
                RewriteOptions.AddRedirectToNonWww(statusCode);
                break;

            default:
                throw new InvalidEnumArgumentException(nameof(options.WwwMode), (int)options.WwwMode, options.WwwMode.GetType());
            }

            return(RewriteOptions);
        }
Beispiel #2
0
        public static RewriteOptions AddRedirectToNonWww(this RewriteOptions options)
        {
            options.AddRedirectToNonWww(307);

            return(options);
        }