|
 |
asp_web_howto thread: Subdomain and root paths
Message #1 by "Keith Every" <keithe@e...> on Wed, 11 Sep 2002 09:50:05
|
|
Hi,
I am fairly new to asp so if the following appears a little stupid then
please tell me.
We are using an external web hosting service that has a beta.mywebsite.com
subdomain setup on it. Now in order to test a new site prior to it going
live I want to be able to run it by accessing beta.mywebsite.com/, All the
new files are located in a 'beta' directory. I have no problem with
detecting that it is the beta site that is being accessed and then pass
control over to the default.asp file in the beta directory. This works
fine.
The biggest problem I have is that the site uses root addressing for some
of its files, i.e. the navigation bar images are contained in /assets.
This also applies to the pages that are pointed to by the navigation bar.
This is neccessary since I want to use the same navigation bar for all
pages on the site, some of which may be in a different directory. Using
relertive page addressing works without problems.
Question.
Is it possible to use root addressing for the beta site (located in a
subdirectory 'beta') with all the files contained at that level and if so
how. What I think I am after is a way to make the web server see the beta
sites root directory as beta.mywebsite and not as mywebsite.
If the I can't use root addressing then can anyone offer some advise on
the best way to overcome the above problem.
Thanks,
Keith
Message #2 by jeff.montgomery@m... on Thu, 12 Sep 2002 04:26:51
|
|
I would create two entirely separate web sites, with two completely
separate sets of files. If your service provider can point
beta.mywebsite.com (or, rather, its actual IP address) to the "beta"
directory, and you duplicate the entire site into that beta folder, then
it should work. However, this assumes that the links in your pages are
relative links, that is, the URLs are formatted like "pagename.asp"
instead of "http://mysite.com/pagename.asp".
It may not be possible for you, but the best thing to do is to have an
entirely separate beta/staging site, then you can simply copy all your
files over to the live site when it's ready.
Jeff Montgomery
jeff.montgomery@m...
> Hi,
> I am fairly new to asp so if the following appears a little stupid then
p> lease tell me.
> We are using an external web hosting service that has a
beta.mywebsite.com
s> ubdomain setup on it. Now in order to test a new site prior to it going
l> ive I want to be able to run it by accessing beta.mywebsite.com/, All
the
n> ew files are located in a 'beta' directory. I have no problem with
d> etecting that it is the beta site that is being accessed and then pass
c> ontrol over to the default.asp file in the beta directory. This works
f> ine.
> The biggest problem I have is that the site uses root addressing for
some
o> f its files, i.e. the navigation bar images are contained in /assets.
T> his also applies to the pages that are pointed to by the navigation
bar.
T> his is neccessary since I want to use the same navigation bar for all
p> ages on the site, some of which may be in a different directory. Using
r> elertive page addressing works without problems.
> Question.
I> s it possible to use root addressing for the beta site (located in a
s> ubdirectory 'beta') with all the files contained at that level and if
so
h> ow. What I think I am after is a way to make the web server see the
beta
s> ites root directory as beta.mywebsite and not as mywebsite.
> If the I can't use root addressing then can anyone offer some advise on
t> he best way to overcome the above problem.
> Thanks,
K> eith
Message #3 by "Bill Todd" <btodd@a...> on Sat, 14 Sep 2002 17:31:31
|
|
Hi Keith,
I faced the same problem plus the issue of having SSL on the main site but
not on beta. Here's what I did...
Added this snippet to the top of every page:
<%
DIM vRoot
DIM vSecureRoot
DIM vImageRoot
IF INSTR(REQUEST.SERVERVARIABLES("SERVER_NAME"),"beta.mywebsite.com")
THEN
vRoot = "http://beta.mywebsite.com"
vSecureRoot = vRoot
ELSE
vRoot = "http://www.mywebsite.com"
vSecureRoot = "https://www.mywebsite.com"
END IF
IF REQUEST.SERVERVARIABLES("HTTPS") = "on" THEN
'Use https url to get images for secure pages to avoid security warnings
vImageRoot = vSecureRoot
ELSE
vImageRoot = vRoot
END IF
%>
Changed all absolute references to point to the appropriate variable, like
so:
<a href="http://www.mysite.com/folder1/pagename.asp" ....
became
<a href="<%=vRoot %>/folder1/pagename.asp" ....
<a href="https://www.mysite.com/folder2/pagename.asp" ....
became
<a href="<%=vSecureRoot %>/folder2/pagename.asp" ....
<img src="http://www.mysite.com/images/picture.jpg" ....
became
<img src="<%=vImageRoot %>/images/picture.jpg" ....
HTH,
Bill Todd
btodd@a...
Message #4 by "Bill Todd" <btodd@a...> on Sat, 14 Sep 2002 17:33:33
|
|
Hi Keith,
I faced the same problem plus the issue of having SSL on the main site but
not on beta. Here's what I did...
Add this snippet to the top of every page:
<%
DIM vRoot
DIM vSecureRoot
DIM vImageRoot
IF INSTR(REQUEST.SERVERVARIABLES("SERVER_NAME"),"beta.mywebsite.com")
THEN
vRoot = "http://beta.mywebsite.com"
vSecureRoot = vRoot
ELSE
vRoot = "http://www.mywebsite.com"
vSecureRoot = "https://www.mywebsite.com"
END IF
IF REQUEST.SERVERVARIABLES("HTTPS") = "on" THEN
'Use https url to get images for secure pages to avoid security warnings
vImageRoot = vSecureRoot
ELSE
vImageRoot = vRoot
END IF
%>
Change all absolute references to point to the appropriate variable, like
so:
<a href="http://www.mysite.com/folder1/pagename.asp" ....
became
<a href="<%=vRoot %>/folder1/pagename.asp" ....
<a href="https://www.mysite.com/folder2/pagename.asp" ....
became
<a href="<%=vSecureRoot %>/folder2/pagename.asp" ....
<img src="http://www.mysite.com/images/picture.jpg" ....
became
<img src="<%=vImageRoot %>/images/picture.jpg" ....
HTH,
Bill Todd
btodd@a...
Message #5 by "Keith Every" <keithe@e...> on Sun, 15 Sep 2002 14:09:09
|
|
> Hi Keith,
> I faced the same problem plus the issue of having SSL on the main site
but
n> ot on beta. Here's what I did...
> Add this snippet to the top of every page:
> <%
> DIM vRoot
> DIM vSecureRoot
> DIM vImageRoot
> IF INSTR(REQUEST.SERVERVARIABLES("SERVER_NAME"),"beta.mywebsite.com")
T> HEN
> vRoot = "http://beta.mywebsite.com"
> vSecureRoot = vRoot
> ELSE
> vRoot = "http://www.mywebsite.com"
> vSecureRoot = "https://www.mywebsite.com"
> END IF
> IF REQUEST.SERVERVARIABLES("HTTPS") = "on" THEN
'> Use https url to get images for secure pages to avoid security warnings
> vImageRoot = vSecureRoot
> ELSE
> vImageRoot = vRoot
> END IF
%> >
> Change all absolute references to point to the appropriate variable,
like
s> o:
> <a href="http://www.mysite.com/folder1/pagename.asp" ....
> became
> <a href="<%=vRoot %>/folder1/pagename.asp" ....
> <a href="https://www.mysite.com/folder2/pagename.asp" ....
> became
> <a href="<%=vSecureRoot %>/folder2/pagename.asp" ....
> <img src="http://www.mysite.com/images/picture.jpg" ....
> became
> <img src="<%=vImageRoot %>/images/picture.jpg" ....
> HTH,
B> ill Todd
b> todd@a...
Message #6 by "Keith Every" <keithe@e...> on Sun, 15 Sep 2002 14:12:28
|
|
Hi Jeff and Bill,
Thanks for the feedback.
Jeff, using two totally seperate sites is not possible the costs are to
great, nice thought though.
Bill, I must admit that this is the path I expected to take but had
wondered if there was another way round the problem, I guess there is not:(
Keith
PS sorry about the duplicate, entered address and password and hit
return...
> Hi Keith,
> I faced the same problem plus the issue of having SSL on the main site
but
n> ot on beta. Here's what I did...
> Add this snippet to the top of every page:
> <%
> DIM vRoot
> DIM vSecureRoot
> DIM vImageRoot
> IF INSTR(REQUEST.SERVERVARIABLES("SERVER_NAME"),"beta.mywebsite.com")
T> HEN
> vRoot = "http://beta.mywebsite.com"
> vSecureRoot = vRoot
> ELSE
> vRoot = "http://www.mywebsite.com"
> vSecureRoot = "https://www.mywebsite.com"
> END IF
> IF REQUEST.SERVERVARIABLES("HTTPS") = "on" THEN
'> Use https url to get images for secure pages to avoid security warnings
> vImageRoot = vSecureRoot
> ELSE
> vImageRoot = vRoot
> END IF
%> >
> Change all absolute references to point to the appropriate variable,
like
s> o:
> <a href="http://www.mysite.com/folder1/pagename.asp" ....
> became
> <a href="<%=vRoot %>/folder1/pagename.asp" ....
> <a href="https://www.mysite.com/folder2/pagename.asp" ....
> became
> <a href="<%=vSecureRoot %>/folder2/pagename.asp" ....
> <img src="http://www.mysite.com/images/picture.jpg" ....
> became
> <img src="<%=vImageRoot %>/images/picture.jpg" ....
> HTH,
B> ill Todd
b> todd@a...
Message #7 by "Bill Todd" <btodd@a...> on Mon, 16 Sep 2002 05:02:10
|
|
B> ill, I must admit that this is the path I expected to take but had
w> ondered if there was another way round the problem, I guess there is
not:(
Keith,
What are you seeing as the downsides of this method?
Changing the absolute references to use the root variables can be easily
done using a global search and replace tool like Multi-Replace, available
at http://www.cict.co.uk/software/dev/mrep.htm. Note - I use version 1.2 -
had some problems with the current 2.2 version and 1.2 does all I need. If
you can't find a copy, I'll be happy to email you 1.2 which was released
as a free version. Or look at any of the other ones around. If you find
something great let me know.
If you do decide to use this method let me know how it goes for you.
Bill
PS - you're welcome.
Message #8 by "Keith Every" <keithe@e...> on Tue, 17 Sep 2002 08:33:55
|
|
Bill,
Thanks for your feedback.
There were only a few possible downsides, firstly converting all the root
paths to add in the actual path <%=path%>. The other one was that each
server action takes a finite ammount of time and since these referances
crop up all over the place I didn't know if this was a good idea. At the
end of the day I do not know the time each server action takes and
therefore can not ascertain the impact that many requests have on the
delivery of a page. Do you know of a good palce to look for this type of
information.
I had initially wondered if there was any way of tricking the server into
thinking that the root of the site had changed for all 'beta' accesses and
therefore to do it that way if it were possible.
Most of the work has now been done but I will at least know the way to
address the problem next time round.
Thanks again,
Keith
> B> ill, I must admit that this is the path I expected to take but had
w> > ondered if there was another way round the problem, I guess there is
n> ot:(
> Keith,
> What are you seeing as the downsides of this method?
> Changing the absolute references to use the root variables can be easily
d> one using a global search and replace tool like Multi-Replace,
available
a> t http://www.cict.co.uk/software/dev/mrep.htm. Note - I use version
1.2 -
h> ad some problems with the current 2.2 version and 1.2 does all I need.
If
y> ou can't find a copy, I'll be happy to email you 1.2 which was released
a> s a free version. Or look at any of the other ones around. If you find
s> omething great let me know.
> If you do decide to use this method let me know how it goes for you.
> Bill
> PS - you're welcome.
Message #9 by "Bill Todd" <btodd@a...> on Wed, 18 Sep 2002 20:11:55
|
|
>...can not ascertain the impact that many requests have on the
>delivery of a page. Do you know of a good palce to look
>for this type of information.
I can only speak from my experience. The highest traffic site I've used
this on (www.summeroncampus.com) gets about 15,000 visits/120,000 page
views per month and hasn't experienced any slow down.
HTH,
Bill
Message #10 by "Ken Schaefer" <ken@a...> on Thu, 19 Sep 2002 13:34:57 +1000
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Keith Every" <keithe@e...>
Subject: [asp_web_howto] Re: Subdomain and root paths
: There were only a few possible downsides, firstly converting all the root
: paths to add in the actual path <%=path%>. The other one was that each
: server action takes a finite ammount of time and since these referances
: crop up all over the place I didn't know if this was a good idea. At the
: end of the day I do not know the time each server action takes and
: therefore can not ascertain the impact that many requests have on the
: delivery of a page. Do you know of a good palce to look for this type of
: information.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You mentioned that this was a hosted site? If so, then your websites are
only using a fraction of the processing power of the server (the other
websites would be taking the rest). By putting this in, you'd be taking a
fraction more of the total CPU power of the server.
To be honest, ASP isn't that server-intensive. Objects are. Database
transactions are. Straight ASP scripting generally isn't (except maybe
string manipulation).
We do some load testing a work, and for simple pages, we'd saturate a 100
Mb/sec network before we'd run out of processing power (and that's using a
P3 600 MHz machine as the webserver!)
Cheers
Ken
|
|
 |