tags:

views:

45

answers:

1

I'm currently trying to print out a document path with SSI in Apache. I've managed to get it working, except that I have to hard code in the 'http://' at the beginning. My current code is:

You are currently here: <a href="http://&lt;!--#echo var="HTTP_HOST" --><!--#echo var="REQUEST_URI" -->">http://&lt;!--#echo var="HTTP_HOST" --><!--#echo var="REQUEST_URI" -->url.shtml</a>

The problem is, when I view this document through https, it still says 'http' meaning it can't link to itself.

Is there any way I can do this without hard coding in the 'http://' ? I've looked online, but most examples have done it this way.

Thanks.

+1  A: 
<!--#if expr="$SERVER_PORT = 80" -->
  <!--#set var="protocol" value="http" -->
<!--#elif expr="$SERVER_PORT = 443" -->
  <!--#set var="protocol" value="https" -->
<!--#endif -->

Then you can use <!--#echo var="protocol" -->

Michael Cramer
Thankyou! That's really cool. For some reason I didn't even think of using a if/else statement ... got a bit to learn about Apache yet ... :)
Aaron Moodie