Solved

Where am I?  Virtual directory, is there a variable with url?

Posted on 2000-05-09
4
237 Views
Last Modified: 2012-08-13
I thought the best way to handle this task was to use virtual directories, but if there is a better way, please don't hesitate to point me in that direction!  What I want to do is have a quick URL for each "product id" ..., e.g., "http://www.mydomain.com/apples/"   I currently as getting the functionality I want by having a single .asp sitting in the virtual directory that just sets the id ("apples") and then does an #INCLUDE FILE="../parent.inc" which is where all the vbscript and application logic exists.  

I'ld like to avoid having to place a unique .asp in each virtual directory.  I could do this if I could figure out how to determine dynamically which virtual directory got requested.  Is there a way?

I went down a tangent and followed the advice from Question #10236558
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=10236558 
I thought that was a great idea until I realized that the URL becomes messy then.  I wanted to keep it www.mydomain.com/apples/   (nice and clean, no filenames, extensions, question marks, etc.) as newbies will often be typing in the url manually.

Is there ANY way to get my vbscript .asp to know which virtual directory it is in?      Or is there an even simpler method of getting what I want without virtual directories, etc.,??
0
Comment
Question by:gorndog
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
makerp earned 100 total points
ID: 2792362
you can find out where you are by

Request.ServerVariables("SCRIPT_NAME") now the first bit returned will be the virtual dir if any.

now what you could do is have a single dir and have a default.asp that takes a param called topic

i.e

default.asp?topic=apples

then in default.asp

IF(Request("topic") = "apples")
    %>
       <!--#include file="apples.inc"->
    <%
END IF
IF(Request("topic") = "bannas")
   etc etc etc

each topic can have a corresponding .inc file. also any generic code thats relevant to all apps can reside in the default.asp .. such as titles headering setc.




0
 
LVL 10

Expert Comment

by:makerp
ID: 2792373
the script_name seems to be the one for you.

so just have your virtual dirs and chop the first bit of script_name. then redirect to a correwsponsing file. include a file etc.

vdir = Mid(Request.ServerVariables("SCRI{PT_NAME"),0,(Instr(Request.ServerVariables("SCRIPT_NAME"),"/")))

should get the virtual dir
0
 
LVL 4

Expert Comment

by:fruey
ID: 2792392
All of your virtual directories can point to the same physical directory. Then you can have one script that grabs the virtual directory name with a

Request.ServerVariables("URL")

Otherwise, you could have a box on the homepage where you type the product name to get redirected via an ASP; but this won't give you the possibility to type the URL manually to point directly to a product name.

Alternatively you could allow the URL to generate a 404 BUT have your 404 file configured as a "normal" asp page which then redirects based on the info, which will be in the QueryString. However, this is messy.
0
 

Author Comment

by:gorndog
ID: 2794905
All three responses were right on!  (Unfortunately Experts-Exchange won't let me split the points.)

Both server variables ("Script_Name", and "URL") return the name of the virtual directory.  (I thought I had tried "script_name" before I had asked the question but I must have overlooked something.)  So I can use either one.

Then another thing that saved me was the ability to have a "default document" for the virtual directory.  That let me hide all the .asp names and everything else.  So what I'm left with is one single, simple .asp which simply extracts the directory name from the "URL" server variable ( e.g., URL returns  "/apple/default.asp") and then from there the program flow is data driven..

That is EXACTLY what I wanted to do.  Thank you, thank you, thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
two submit buttons one form 15 74
Dreamweaver server behavior gone 6 108
sql to convert to date IF entry is in date format 4 74
Select2 jquery help 9 74
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now