07-04-2007, 06:18 PM
I wanted to know what scripting code you will need to do the following:
Say you want to go to http://www.kidzo.co.uk/gunu : but there really isn't a directory called "gunu" and it's just forwarding to this page:
Example 2: http://www.kidzo.co.uk/admin will redirect to http://www.kidzo.co.uk/profiles.asp?id=admin
(The "gunu" and "admin" are the usernames stored in my database!!!)
07-05-2007, 02:16 PM
A lot of times, this is done with Apache and Linux, not IIS.
You would need to use code to create a "home" folder for every user that has access to your system. Then, in each folder, you would create (or copy) files to said directory so that they have access to the same information.
The code you can use is the Scripting.FileSystemObject to create (or destroy) folders on your server.
07-05-2007, 02:53 PM
Well, if I'm correct, you don't want to create new directories every time you add a new user and so just want a redirection to profiles.asp?id=username when someone puts in yourdomain.com/username.
The only method I see here is that when they type in yourdomain.com/username, they're going to get a 404 error because the directory doesn't exist. What you can then do is create a custom 404 page (Instructions to do this (http://www.microsoft.com/technet/prodtechnol/windows2000serv/technologies/iis/tips/custerr.mspx)) that has ASP code at the top that looks at the current web address, extracts the username in the URL, and attempts to redirect to profiles.asp?id=username. If you need help writing that code, just ask.
07-05-2007, 04:23 PM
The only issue with doing it that way is that you are going to fill your IIS logs with 404 errors every time someone goes to log in or view those pages.
If you administer the server, you need to keep this in mind.
07-06-2007, 07:26 AM
How do you extract the username from http://www.kidzo.co.uk/admin
07-06-2007, 09:38 AM
what you need is an ISAPI rewrite application. It gives you the chance to redirect to a different url, based on the url requested by the browser. It catches the url, rewrites it and serves back the page you want to serve. The beauty of it is that it doesnt change the url the user sees in the browser. Downside: you have to program, or find a free application (search for ISAPI_Rewrite (http://www.isapirewrite.com/), it has a free version) or buy a program.
programming sample is here (http://www.codeproject.com/isapi/isapiredirector.asp)
07-06-2007, 10:31 AM
create a custom 404 page is probably your fastest way that gets the url server var splits on / then you just want the last one then a response.redirect based off that then put in your profiles page somethign that does a username check against the db