CS: BUG FIX: Numerical or localhost hostnames when wwwStatus = "Require"
If you have wwwStatus = "Require" in your CommunityServer.config file, the site will not function if you try to access it via an IP address (usually used while debugging) or "localhost". I added the following code to correct the issue. The regular expressions should probably be expanded upon, but since they weren't the code I added is not either:
CommunityServerComponents(20)/HttpModule/CSHttpModule.cs:
Insert the following line:
private static Regex ignoreWwwStatusRegex = new Regex(@"https?://(localhost|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", RegexOptions.IgnoreCase | RegexOptions.Compiled);
before the line:
private static Regex wwwStatusRegex = new Regex("https?://www\\.", RegexOptions.IgnoreCase | RegexOptions.Compiled);
Insert the following lines:
if (ignoreWwwStatusRegex.IsMatch(rawUrl))
return;
after the line:
string rawUrl = context.Request.Url.ToString();
This will prevent the system from trying to make any modifications to the hostname portion of a URL if it is "localhost" or an IP address.