Determine if original URL or Rewritten URL being used.

Last post 05-06-2008 7:46 AM by srulyt. 2 replies.

Sort Posts:

  • Determine if original URL or Rewritten URL being used.

    05-04-2008, 9:15 PM
    • Loading...
    • dbernett
    • Joined on 01-31-2003, 9:38 AM
    • Dept. of Veterans Affairs
    • Posts 51

    Is there anyway to determine on Page Load if the URL is the Original or the Rewritten one?  I've played with several of the Request.URL properties but nothing seems to determine which URL is being used.

    It looks like the Search Engines are using my original URL's (when they spider me) and I would like a way for my pages to do a 301 Redirect if the original URL is used. 

     something like

     

    If (orignal URL) then

    Response.Status = "301 Moved Permanently"

    Response.AddHeader("Location", "http://A_Re_Written_URL")

    End If

     Thank you.

  • Re: Determine if original URL or Rewritten URL being used.

    05-05-2008, 4:38 PM
    Answer
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 304
    Just don't show out your original URL-s to search engines. They refresh their indexes during time and this doen't happen over night. Original URL you have may contain specific query string parameter by example. You can do your own redirect by example in BeginRequest event of your application. Of course, be sure you end response right after redirect.
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
  • Re: Determine if original URL or Rewritten URL being used.

    05-06-2008, 7:46 AM
    Answer
    • Loading...
    • srulyt
    • Joined on 02-02-2008, 6:16 PM
    • Posts 200

    When you rewrite your urls in your handler you can add a query param rewrite=true. no one will see this but if its not there you can forward to your friendly URL. Another option is to add a boolean session variable.

    The issues with the whole 301 thing is that you are sending the person to the same page using a different url. If something goes wrong in your code you will get an unending loop of page redirects.

Page 1 of 1 (3 items)