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

C

codeboy

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.
 
G

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

Gregory A. Beamer

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

Krishna

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
 
G

Gregory A. Beamer

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top