Make my site appear to have directories when they actually don’t e

Discussion in 'ASP .Net' started by codeboy, Dec 7, 2009.

  1. codeboy

    codeboy Guest

    I’d like to have my users point their browsers to subdirectories that do not
    exist and have them all handled by one aspx page. For example if a user trys
    to go to www.mysite.com/fakedir1, www.mysite.com/fakedir2, or
    www.mysite.com/fakedir3 they will all be handled by
    www.mysite.com/mypage.aspx. I don’t know what fake directories will be
    needed so I’d like it to happen for all subdirectories. I’d also like the
    user to think they are actually in the dir. So the browser will need to
    continue to reflect the dir they actually requested.
     
    codeboy, Dec 7, 2009
    #1
    1. Advertising

  2. Re: Make my site appear to have directories when they actually don’t e

    On Dec 7, 3:18 am, codeboy <> wrote:
    > I’d like to have my users point their browsers to subdirectories that do not
    > exist and have them all handled by one aspx page.  For example if a user trys
    > to go towww.mysite.com/fakedir1,www.mysite.com/fakedir2, orwww.mysite.com/fakedir3they will all be handled bywww.mysite.com/mypage.aspx.  I don’t know what fake directories will be
    > needed so I’d like it to happen for all subdirectories.  I’d also like the
    > user to think they are actually in the dir.  So the browser will need to
    > continue to reflect the dir they actually requested.  


    This technique called URL Rewriting, see more
    http://www.google.com/search?q=url rewrite asp.net
     
    Alexey Smirnov, Dec 7, 2009
    #2
    1. Advertising

  3. Re: Make my site appear to have directories when the y actually don’t e

    Alexey Smirnov <> wrote in news:63d3d4b6-caaa-
    :

    > This technique called URL Rewriting, see more
    > http://www.google.com/search?q=url rewrite asp.net


    I think he can probably use the 404 error in this condition, rather than
    URL rewriting. I had thought that direction too, at first, but if he
    wants all non-existant directories to go to one page, the 404 should
    solve that. If it does not solve it all, an examination of HTML return
    codes should find the exceptions to the redirect and solve it.

    Peace and Grace,

    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Dec 7, 2009
    #3
  4. codeboy

    Krishna Guest

    Re: Make my site appear to have directories when the y actually do

    Hi Gregory

    can you tell me how to do the following which u said in the below query?

    "the 404 should solve that. If it does not solve it all, an examination of
    HTML return
    codes should find the exceptions to the redirect and solve it"

    Thanks

    "Gregory A. Beamer" wrote:

    > Alexey Smirnov <> wrote in news:63d3d4b6-caaa-
    > :
    >
    > > This technique called URL Rewriting, see more
    > > http://www.google.com/search?q=url rewrite asp.net

    >
    > I think he can probably use the 404 error in this condition, rather than
    > URL rewriting. I had thought that direction too, at first, but if he
    > wants all non-existant directories to go to one page, the 404 should
    > solve that. If it does not solve it all, an examination of HTML return
    > codes should find the exceptions to the redirect and solve it.
    >
    > Peace and Grace,
    >
    > --
    > Gregory A. Beamer (MVP)
    >
    > Twitter: @gbworld
    > Blog: http://gregorybeamer.spaces.live.com
    >
    > *******************************************
    > | Think outside the box! |
    > *******************************************
    > .
    >
     
    Krishna, Dec 10, 2009
    #4
  5. Re: Make my site appear to have directories when the y actually do

    =?Utf-8?B?S3Jpc2huYQ==?= <> wrote in
    news::

    > "the 404 should solve that. If it does not solve it all, an
    > examination of HTML return
    > codes should find the exceptions to the redirect and solve it"


    In web.config find the custom errors element. You can handle the 404
    like this:

    <customErrors defaultRedirect="ErrorPage.aspx" mode="On">
    <error statusCode="404" redirect="filenotfound.aspx" />
    </customErrors>

    Here are a list of HTTP codes you can handle:

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    This means you can do the following, if you wish:

    <customErrors>
    <error statusCode="400" redirect="BadRequest.aspx" />
    <error statusCode="401" redirect="Unauthorized.aspx" />
    <error statusCode="403" redirect="Forbidden.aspx" />
    <error statusCode="404" redirect="NotFound.aspx" />
    <error statusCode="405" redirect="MethodNotAllowed.aspx" />
    <error statusCode="406" redirect="NotAcceptable.aspx" />
    <error statusCode="407"
    redirect="ProxyAuthenticationRequired.aspx" />
    <error statusCode="408" redirect="RequestTimeout.aspx" />
    <error statusCode="409" redirect="Conflict.aspx" />
    <error statusCode="410" redirect="Gone.aspx" />
    <error statusCode="411" redirect="LengthRequired.aspx" />
    <error statusCode="412" redirect="PreconditionFailed.aspx" />
    <error statusCode="413" redirect="RequestEntityTooLarge.aspx" />
    <error statusCode="414" redirect="RequestUriTooLong.aspx" />
    <error statusCode="415" redirect="UnsupportedMediaType.aspx" />
    <error statusCode="416"
    redirect="RequestRangeNotSatisfiable.aspx" />
    <error statusCode="417" redirect="ExpectationFailed.aspx" />
    <error statusCode="500" redirect="InternalServerError.aspx" />
    <error statusCode="501" redirect="NotImplemented.aspx" />
    <error statusCode="502" redirect="BadGateway.aspx" />
    <error statusCode="503" redirect="ServiceUnavailable.aspx" />
    <error statusCode="504" redirect="GatewayTimeout.aspx" />
    <error statusCode="505" redirect="HttpVersionNotSupported.aspx" />
    </customErrors>

    Note that it is either impossible or nearly impossible to hit some of
    these with a web site, but it gives you the idea.

    Peace and Grace,


    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
     
    Gregory A. Beamer, Dec 10, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Giampaolo Rodola'
    Replies:
    6
    Views:
    439
    Nick Stinemates
    Apr 18, 2008
  2. codeboy
    Replies:
    1
    Views:
    294
    Gregory A. Beamer
    Dec 7, 2009
  3. codeboy
    Replies:
    0
    Views:
    259
    codeboy
    Dec 7, 2009
  4. codeboy
    Replies:
    1
    Views:
    297
    Gregory A. Beamer
    Dec 7, 2009
  5. David A. Black
    Replies:
    2
    Views:
    243
    Tim Hunter
    Aug 19, 2004
Loading...

Share This Page