Skip to main content
Inspiring
July 19, 2007
Question

Brain glitch: how to get environment server name (not ip)

  • July 19, 2007
  • 2 replies
  • 541 views
I'm having a brain glitch, so this may be a dumb question, but here goes. How would you create "Send To a Friend" hyperlink in an application with both intranet and internet users?

I thought of using CGI variables
http://#CGI.SERVER_NAME#/SomePage.cfm?id=89

But as I understand it CGI.SERVER_NAME will return an IP for intranet users accessing the site via a private IP address. So the result would be link containing a private IP address that's meaningless to the outside world.
http://192.168.x.x/SomePage.cfm?id=89

Is there any way around this aside from hard-coding?
    This topic has been closed for replies.

    2 replies

    Inspiring
    July 19, 2007
    CGI.HTTP_HOST will return whatever the URL has as the server host... so if the url uses an IP, then that is what you get.
    cf_dev2Author
    Inspiring
    July 19, 2007
    Darn. I was hoping there was a way to get the server name without hardcoding. Though now that I think about it, I guess that wouldn't be possible. I mean if more than one name was mapped to a single IP, how would CGI know which one to return?
    Inspiring
    July 19, 2007
    IIRC cgi.server_name is going to return the server actually running the
    application. I think what you are asking about is cgi.referrer?

    cf_dev2Author
    Inspiring
    July 19, 2007
    Yes, I do want the server name. So I can construct a link to the current page. The problem is CGI.SERVER_NAME doesn't always return the name.