Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format for a secure relative URL

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I have a web page that needs to maintain relative links. However, one link needs to be a secure one. How do I specify a relative URL that uses 'https'? Specfically:
Code:
<a href=&quot;/myfolder/mypage.html&quot;>

TIA.
 
Rats! Thanks for the reply but it wasn't what I wanted to hear. :)
 
HTTP vs HTTPS is just the transfer protocol - the actual page sent in both cases is the same.

So you could just refer to it the normal way (<a href=&quot;/myfolder/mypage.html&quot;>) which will request using the current page's protocol, and then check in mypage.html if the request is coming over HTTP or HTTPS, and redirect accordingly.

Eg, in an ASP page I would just:
Code:
'if this request wasn't through HTTPS
if Request.ServerVariables(&quot;HTTPS&quot;) <> &quot;on&quot; then
  'then redirect it back to here via HTTPS
  Response.Redirect(&quot;[URL unfurl="true"]https://&quot;[/URL] & request.serverVariables(&quot;SERVER_NAME&quot;) & request.serverVariables(&quot;SCRIPT_NAME&quot;))
end if

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top