Jump to content

Recommended Posts

Any one help me with this problem please !!  Ok, how do i get the 'HTTP_HOST' variable to allways be a specfic address rather than the one that is the current url ? For example,

We are running some project management software that is web based and use's php, we have access to it inside work on a server, the server address is say http://195.192.1.1:80, we can also access it from home on a pass through which is say http://81.254.101.51:80, now the problem is if you work on a project from home and get email notification to your work email that a change has been made, php send out a mail with a link to click to see the changes made but that link is the http://81.254.101.51:80 link and not the http://195.192.1.1:80, so in work you cant click the link to go to the internal server because the 'HTTP_HOST' takes the link from where the web url is ? How can i force the 'HTTP_HOST' to allways be http://195.192.1.1:80 ?
Link to comment
https://forums.phpfreaks.com/topic/13952-help-with-http_host/
Share on other sites

"HTTP_HOST" is basically a user supplied value. Perhaps "REMOTE_ADDR" or "SERVER_ADDR" will have the value you're look for. Do a print out of the $_SERVER array to see what the differences are when going through 81.x and 195.x
[code]
<?php
print_r($_SERVER);
?>
[/code]

The HTTP_HOST value can be overridden, but you probably don't want to do that because if the value is used elsewhere it's more than likely that the value you want is the original one.
[code]
<?php
$_SERVER['HTTP_HOST'] = 'foo';
?>
[/code]

You can also put it in a constant yourself for use throughout your script
[code]
define('TRUE_HOST', '195.x.x.x');
echo TRUE_HOST;
[/code]
[url=http://www.php.net/define]define()[/url]

Harcoding the value in the section of the script that creates the link for the email is also an option if it's unlikely that you need the true value anywhere else.

EDIT: You may find it more convenient to create two links. One that's for accessing from home and one for accessing from work. So that if the email is accessed from home you'll still be able to have easy access.
Link to comment
https://forums.phpfreaks.com/topic/13952-help-with-http_host/#findComment-54399
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.