Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> The base href tag --> Part 3

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
21 active users
20 visitors today
62 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2012 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

The sURLTest array

I then loop through an array (defined in include/config.asp as we'll see below), searching for strings that will define which server I am running on. When we find a match we add a sub-folder to the path.

Here are the arrays in include/config.asp:

// ============================================
// base href - the URL of your pages
// ============================================
// if a string in sURLTest is found, then the offset is applied from
// sURLOffset. As an example, I want my base hrefs to be
// http://CoverYourASP.com/ on production server and
// http://localhost/cya/ on development server.
var sURLTest = new Array (
   '.com',      // if this found in server name..
   'localhost'
   );

var sURLOffset = new Array (
   '',         // ..apply this offset
   'cya'
   );

As shipped in the download I first look for ".com" in the server name (obviously you should change both of these arrays to fit your circumstances). If a ".com" is found, then I don't need any sub-folder, so I leave the sURLOffset empty. The final base href is therefore "http://CoverYourASP.com/".

If "localhost" is found, then "cya" is added to the server name, and I end up with "http://localhost/cya/". Bingo!

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



New Proposal Kit Professional 5.1
Brand yourself as a top professional: create quotes and amazing proposals and get many legal documents free!

The latter saved me 3 times the purchase price on the first day I owned it!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?