Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. drop www from url

drop www from url

Scheduled Pinned Locked Moved ASP.NET
helpcsharpcomwindows-admintutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    munklefish
    wrote on last edited by
    #1

    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!!!

    L A 2 Replies Last reply
    0
    • M munklefish

      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!!!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I googled and found http://www.samburdge.co.uk/wordpress/wp-plugin-remove-www-from-url[^] Check it out

      1 Reply Last reply
      0
      • M munklefish

        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!!!

        A Offline
        A Offline
        Ashutosh Phoujdar
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups