![]() | Pepper Spray & Stun Gun Specials! KEEP THEM SAFE. | |
| CoverYourASP --> The base href tag --> Part 2 | ||
| Using <base href>The answer was to use <base href>. This tells the browser what URL relative links are relative to. So if I use:
The link would always point to http://CoverYourASP.com/Hello.asp, no matter where this page was. Configuring <base href>Of course, hard-coding http://CoverYourASP.com/ into my code wouldn't help you or I very much. The <base href> needs to change when it's on the development server - in my case I want it to be http://localhost/cya/. This is accomplished with some code in utils/Init.asp, shown below:
To start with I get the server name from Request.ServerVariables. Giving my servers as an example, I get either "CoverYourASP.com" or "localhost" from this. I then test to see if the page was requested with SSL security, and if so use https:// instead of http:// If the page was accessed using a different port (not the default port 80) then that is appended too. |
| ||||||||||||||||||||||||||||||||||||||||||||||||||