drop www from url
-
Hi, Can anyone help me with the following problem please; I need to drop the 'www' part of a url whenever it is entered by a visitor. So for example if they type 'www.domain.com/' it goes to 'domain.com/'. Likewise it should do the same for specific files and folders eg 'www.domain.com/files/test.jpg' should redirect to 'domain.com/files/test.jpg'. The updated domain name should be shown in the url. I am running this on IIS on a dedicated machine over the web. I using the 'redirect' function in IIS i can only get it to redirect to a specific url rather than the exact corresponding file / domain location. WOuld it be better to do this with a .Net config file? Help greatly appreciated. Thanks!!!
-
Hi, Can anyone help me with the following problem please; I need to drop the 'www' part of a url whenever it is entered by a visitor. So for example if they type 'www.domain.com/' it goes to 'domain.com/'. Likewise it should do the same for specific files and folders eg 'www.domain.com/files/test.jpg' should redirect to 'domain.com/files/test.jpg'. The updated domain name should be shown in the url. I am running this on IIS on a dedicated machine over the web. I using the 'redirect' function in IIS i can only get it to redirect to a specific url rather than the exact corresponding file / domain location. WOuld it be better to do this with a .Net config file? Help greatly appreciated. Thanks!!!
-
Hi, Can anyone help me with the following problem please; I need to drop the 'www' part of a url whenever it is entered by a visitor. So for example if they type 'www.domain.com/' it goes to 'domain.com/'. Likewise it should do the same for specific files and folders eg 'www.domain.com/files/test.jpg' should redirect to 'domain.com/files/test.jpg'. The updated domain name should be shown in the url. I am running this on IIS on a dedicated machine over the web. I using the 'redirect' function in IIS i can only get it to redirect to a specific url rather than the exact corresponding file / domain location. WOuld it be better to do this with a .Net config file? Help greatly appreciated. Thanks!!!
You may try like following code snippet
//Extract relative URL by chopping www. from begining
private string newUrl = System.Text.RegularExpressions.Regex.Replace("www.domain.com/files/test.jpg",
"^www\.", String.Empty);//Redirect to new URL
Server.Transfer(newUrl);Hope I answered you correctly :)
dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility