简体   繁体   中英

printing document path with SSI

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://<!--#echo var="HTTP_HOST" --><!--#echo var="REQUEST_URI" -->">http://<!--#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.

<!--#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" -->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM