Forked from waldyrfelix/regex-domain-to-www-domain.cs
Last active
December 15, 2015 15:08
-
-
Save AlbertoMonteiro/5279090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pattern = @"^(https?://)(?!www[.])(.+)$"; | |
var url = Regex.Replace(Request.Url.AbsoluteUri, pattern, @"$1www.$2"); | |
Response.Status = "301 Moved Permanently"; | |
Response.AddHeader("Location", url); | |
Response.End(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pattern = @"^(https?://)(?!www[.])(.+)$"; | |
return new SeeOther(Regex.Replace(Request.Url.AbsoluteUri, pattern, @"$1www.$2")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment