Passing non existing IIS directory to ASP parameter

N

nungon

Good morning,

I have a web site in which 7 pages repeat once and again in thousands
of folders. Why? because I want to keep, to the user view, the pretty
url www.myweb.com/username/pageX.asp.

As you can imagine, this makes maintenance hard, because when I make
some update, I have to run a program to spread the change to the
xthousands directories.

A solution would be to change the url to
www.myweb.com/pageX.asp?u=username but the url wont be so easy to
remember, and probably it will not like our users.

My question is, in which way can I simulate this last behaviour, but
maintaining the "pretty" url, not only for accessing, but during the
navigation. The trick would be to catch the inexisting directory name
and pass it to the desired page as a parameter.

I have asked many people about that, and nobody can help. I would
appreciate someone of you can help me with this.

Thanks in advance,
Nungon.
 
C

CJM

nungon said:
Good morning,

I have a web site in which 7 pages repeat once and again in thousands
of folders. Why? because I want to keep, to the user view, the pretty
url www.myweb.com/username/pageX.asp.

As you can imagine, this makes maintenance hard, because when I make
some update, I have to run a program to spread the change to the
xthousands directories.

A solution would be to change the url to
www.myweb.com/pageX.asp?u=username but the url wont be so easy to
remember, and probably it will not like our users.

My question is, in which way can I simulate this last behaviour, but
maintaining the "pretty" url, not only for accessing, but during the
navigation. The trick would be to catch the inexisting directory name
and pass it to the desired page as a parameter.

I have asked many people about that, and nobody can help. I would
appreciate someone of you can help me with this.

Thanks in advance,
Nungon.

If I understand you correctly...

Set the page for each user to simply Server.Transfer to a common page
elsewhere in the system... Changes to the common page will be reflected
automatically in the pages for each user.

Chris
 
N

nungon

Thanks Chris.
This, howerver, does not solve the problem, since I will had to keep
the xthousands directories.
I want to get rid of them, and just simulate that they exist.
Moreover, with that solution, the user will not see the "pretty" url
during the navigation.

Rgds...Nungon.
 
C

CJM

nungon said:
Thanks Chris.
This, howerver, does not solve the problem, since I will had to keep
the xthousands directories.
I want to get rid of them, and just simulate that they exist.
Moreover, with that solution, the user will not see the "pretty" url
during the navigation.

Rgds...Nungon.

With Apache, you can use Mod_Rewrite to translate the 'pretty' URL in to the
practical URL. There is no direct equivalent, but there are 3rd-party ISAPI
filters that will do the same thing, but obvious you will have to pay for
these...

Eg...

www.mydomain.com/user/page.asp translates to
www.mydomain.com/commonpage.asp?username=user...

I've just noticed that IISToolshed has a free ISAPI filter listed:
http://www.iistoolshed.com/tools.aspx
Chris
 
S

swp

Nungon,

CJM's initial response is still best. Your problem states that it is
the users that are controling what you do, so keep the directories.
They will each contain 1 file, which is the default file for your
internet server (IIS, Apache, whatever). The contents of that 1 file
will be an include file off the root of your web site. That include
file will contain a simple page like this (which can be trimmed
considerably):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<META HTTP-EQUIV="Refresh"
CONTENT="0;URL=http://www.whatever.org/Page0.asp">
<title>Redirect Page</title>
</head>
<body>
</body>
</html>


That immediately redirects them to the proper starting page. Use of
frames will keep the URL on the browser's address bar pure, so they
never know the difference.

If your users are sophisticated enough to right-click and open a new
window when clicking a link to another page, then they should not mind
what is in the address bar.

hth,

swp
 
N

nungon

Thanks both.
swp, your solution solves my problem with the maintenance of the asps,
which is much.
Nevertheless, I want to get rid of the xthousands directories.

I will try the ISAPI mentioned by CJM, no matter if I have to pay
something.

Thanks again,
Nungon.
 
D

Dave Anderson

nungon said:
I have a web site in which 7 pages repeat once and again in
thousands of folders. Why? because I want to keep, to the user
view, the pretty url www.myweb.com/username/pageX.asp...

...My question is, in which way can I simulate this last
behaviour, but maintaining the "pretty" url, not only for
accessing, but during the navigation.

One possibility is a custom 404 handler. One really useful fact is that IIS
sticks the entire URL into Request.QueryString when it encounters a 404. In
the event that your URL does not exist, the QueryString looks like this:

404;http://www.myweb.com/username/pageX.asp?d=05/24/2005&recid=465431

(As a bonus, you still have access to QS elements the old fashioned way:
Request.QueryString("recid").Item)

If you parse the above string, you can get the username. Here is a JScript
example:

var a =
String(Request.QueryString.replace(/(^.+\/\/)|(\?.+$)/g,"").split("/")

Now a is an array with:

a[0] = "www.myweb.com"
a[1] = "username"
a[2] = "pageX.asp"

Perform a Server.Transfer or Server.Execute on pageX.asp...



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
S

Steven Burn

Use a custom 404 to handle the "usernames" and re-direct to the appropriate
"url";

http://aspfaq.com/show.asp?id=2162

That will allow you to get rid of the (x) directories

e.g.;

<script language="VBScript" runat=Server>
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("./" &
StripAfterRoot(Request.ServerVariables("URL"))) Then
'// Folder exists so is probably not a user folder
Else
'// Folder does not exist so is probably a user folder
End If

Function StripAfterRoot(sPath)
'// Get rid of the http:// prefix
sPath = Replace(sPath, "http://", "")
'// Strip the path needed
<(root)> = (0)
username = (1)
page.xxx = (2)
StripAfterRoot = Split(sPath, "/")(1)
End Function
</script>

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
N

nungon

Many Thanks

I will try all the solutions.

So far I have tried (not in production) the ISAPI listed in IISToolshed
IonicIsapiRewriter1.0 and runs perfectly.
Just putting this in the ini ile

RewriteRule ^/(.*)/pageX.asp(.*) /pageX.asp$2&username=$1

and the work is done.

I wonder if this kind of isapi is very resource consuming since I serve
thousands of pages a minute.
Anyone has experienced it?

Rgds...Nungon.
 
C

CJM

nungon said:
I wonder if this kind of isapi is very resource consuming since I serve
thousands of pages a minute.
Anyone has experienced it?

This kind of filter shouldn't be very resource consuming, but it depends on
how well it was developed. The chances are it will be fine, but you'll find
out soon enough...

CJM
 

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,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top