Click to See Complete Forum and Search --> : subdomains and directories
jakykong
03-31-2005, 11:52 PM
I have a brinkster domain, with several sub-domains. Now, these subdomains point to the same default location. This is a problem.
Lets take for example, the jakykong subdomain (my home page - WAY under construction, but it will get the job done).
Jakykong.theanythingbox.com
Now, currently, going there will make a single frame containing
theanythingbox.com/jakykong/index.asp
HOWEVER - not every browser supports frames.
So i want to do a redirect that DOESEN'T use frames.
So, it's in the /jakykong directory, you'd think "response.redirect("/jakykong/index.asp")" ... which "works" ... but then the user is at
jakykong.theanythingbox.com/jakykong/index.asp
i want to create a script that makes it into
jakykong.theanythingbox.com/index.asp
and then, any links that the user clicks will do EXACTLY the same thing.
Now, i have thaught and THAUGHT, AND THAUGHT about how this could be done, without changing the location of each subdomain, and i have YET to figure out a way to do this.
Can anyone help?
phpnovice
04-01-2005, 12:35 AM
I don't know if I've understood your explanation:
response.redirect("../index.asp")
jakykong
04-02-2005, 12:02 AM
well there are only 2 ways i know of to display different information when the user goes to a page:
1. include the other information (EG put it in a frame, or use a <-- #include ... -->)
or
2. move the user to another location (EG a redirect)
... i need to find a way to intercept EVERY incoming URL, and display the required information accordingly.
... i don't own the server, nor do i have adminsitrative rights, i can use ONLY php and asp - nothing else - and i am not too familiar with PHP (plus i'm using the access database driver) so it would be better if i could use ASP.
phpnovice
04-02-2005, 10:11 AM
The code posted is ASP.
jakykong
04-02-2005, 08:26 PM
yes it is - but my server can also use PHP - and as long as they can both use the MS access database driver, i'm happy with either one.
Happens to be i know ASP much better - so it would be nice if this is possible in ASP.
phpnovice
04-02-2005, 10:35 PM
OK, so maybe I'm missing something. I don't see where anything you've said would be a problem. Please give a concise but detailed explanation of what you're trying to accomplish. As for variable content, there are more than just the two ways you mentioned to accomplish that... Via either ASP or PHP you can completely build an entire web page, from scratch (i.e., that does not exist as a file on your server), and send it to the browser for display. Naturally, such variable content would likely come from a database of some sort.
jakykong
04-03-2005, 10:20 PM
Ok, i'll try to be as clear as possible.
All of my subdomains point to the same /webroot/index.asp. However, i don't want them all to display the same content. So, brinkster provided a code example, which got the server name and uses a select to redirect to each of them. This example works perfectly, however if i put files for different subdomains into different directories, IE the jakykong subdomain is in /webroot/jakykong and the superior subdomain is in /webroot/superior, then i get strange URLs like http://jakykong.theanythingbox.com/jakykong/ or http://superior.theanythingbox.com/superior/ and such. To evade this, and keep the subdomain address in the address bar, without the subdomain folder name, so that it would be http://jakykong.theanythingbox.com/ (without the /jakykong/), i am putting the index.asp page as one big frame containing the web pages. This WORKS. However, if a browser doesen't support frames, then i have to revert to the original method and show the actual URL, not the cosmetic URL.
So, what i need to do is hide the actual URL, but display the actual content (which includes ASP code) and show the URL that i want the user to see (a level up the folder tree). How can this be done?
NOTE: i have a *working* method, putting things in frames, though, has already gotten me complaints from users not able to view the website. I'm merely looking for a replacment method that doesen't use frames.
phpnovice
04-04-2005, 12:00 AM
Ah! OK! I got it. All you have to do is use FSO to read the content of the page you wish to send to the browser. Thus, a page like index.asp could actually serve up the content of all of the following pages:
/jakykong/index.asp
/superior/index.asp
/subdomain/index.asp
etc.
Now, the following is not the only way to accomplish this, but... You could create a Session variable of the subfolder you wish all pages to come from. In all subfolders, you could name the pages exactly the same as the page names you are using in the root folder. Then, with code like the following, the page in the root folder could serve up the content of a duplicately named page in the appropriate subfolder:
<%
Session("subfolder") = "/superior"
'
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim objFSO, objFile, objOpenFile, txt
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(Server.MapPath(Session("subfolder") & _
Request.ServerVariables("PATH_INFO")))
Set objOpenFile = objFile.OpenAsTextStream(ForReading)
txt = objOpenFile.ReadAll
objOpenFile.Close
Set objOpenFile = Nothing
Set objFile = Nothing
Set objFSO = Nothing
'
Response.Write txt
Response.End
%>
jakykong
04-04-2005, 05:46 AM
OK! that sounds like it would work. Now i just need to make sure that EVERYTHING is in one subfolder, and nothing uses additional subfolders - that sounds like it would really complicate things.
I think i'll just use that code right there - it'll work!
Thanks so much!
jakykong
04-04-2005, 05:49 AM
wait - this does leave one problem just looking at it again.
This will work for strictly HTML pages. ASP code will be written out with the ASP - but i have a forum, and a couple of other heavily ASP coded pages. Unless i'm mistaken, because this is run on the server, it will include content as though it were plain text.
phpnovice
04-04-2005, 09:42 AM
Yes, that is true. Is the ASP going to be so unique for each subfolder that the ASP has to be part of the document in the subfolder? ...or, can you keep all of the ASP in the root folder documents and parameterize it similar to how I've outlined it for serving up the content in the first place? The documents in the subfolders could certainly be considered template documents with special tags which your root folder ASP could modify on the fly before such content is sent to the client. After all, when the content is served up to the client in this fashion, it is not the subfolder document that is going to get invoked when the client returns with another request. It is the root folder document that will receive the client request and must, therefore, be able to properly handle it.
jakykong
04-08-2005, 06:34 PM
yes, the ASP is VERY unique for each page - i have such ammenities as a shoutbox, forum, on-site email system so user's can contact me - not to mention that this site is host to a couple of my friend's sites.
Unfortunately, all of that means that not only will some pages have and some pages not have ASP in them, it also means the ones that have ASP can't be processed as HTML.
In javascript there is a command to execute a line of javascript code from within the javascript application - i used it once to make an on-the-fly code generator.
Is there a way to do this in ASP? If there is - i could probably use a filesystemobject and read all the lines of code, if they are HTML only, write them out directly. If they are ASP process them.
phpnovice
04-08-2005, 06:59 PM
OK, here's the answer... Rather than Response.Redirect(), you want to use Server.Execute().
jakykong
04-08-2005, 10:37 PM
THANK YOU SO MUCH!!!!! THAT IS ABSOLUTELY PERFECT!!!
... now i just have to implement that and it'll work great!
phpnovice
04-08-2005, 10:38 PM
Cheers.
jakykong
04-10-2005, 11:24 PM
Hey just a question - does ASP support multiple levels of deeper processing? Apparently it supports at least one level - but could i use, say, an include or another server.execute on a page that was server.execute'd by another page?
So like, i have page 1.asp, with this:
<%
server.execute("2.asp")
%>
and 2.asp like this:
<!-- #include file="hello.asp" -->
and hello.asp had this:
hello!
then would going to 1.asp display hello, or would <!-- #include file="hello.asp" --> be displayed as HTML in the original document?
Actually - for that matter - if i have just plain 'ol html mixed in with the ASP (not between <% %>) then would server.execute recognize this and send it to the buffer like a stand-alone asp page?
THANKS! BTW: if either of those are not possible, i can simply add response.write() to most of the stuff and it'll work ok, and if i can't include files, well, i'll just have to work some kind of simple database-style HTML including mechanism (my includes don't have ASP code for the most part).
phpnovice
04-10-2005, 11:36 PM
You'll have to experiment with what works to find out what doesn't.