I am new to php programming and I am seeing an issue I think?
First Test:
code:
$site[homeurl] = ("http://".$HTTP_HOST."".dirname($SCRIPT_NAME));
Result:
http:// http://www.xyz.com/script
* notice the extra leading http:// in the return value.
Second Test:
$site[homeurl] = ($HTTP_HOST."".dirname($SCRIPT_NAME));
Result:
test.xyz.com/script
I am curious as to why in the first test it adds another "http://"
[/b]http://[/b] http://www.xyz.com/script
I have read the documentation and this should not add the extra "http://" but I do not understand why?
php version:
PHP 5.0.4 (cli) (built: Jun 28 2005 22:35:56)
Apache Version:
2.0.55
OS Version:
Solaris 10/05
Note: "I have changed the real domain to xyz.com".
Thank you in advance for any assistance.
Bob
$HTTP_HOST issue ?
Moderator: General Moderators
Try
If you have access to $HTTP_HOST, you're using register_globals = On, which is a known security issue, I suggest you correct it prior to any 'real world' development, anything that will exist on a public server.
Code: Select all
$site['homeurl']= "http://{$_SERVER['HTTP_HOST']}{$_SERVER['SCRIPT_NAME']}";Thanks bdland,
I will understand the global issue.
After making the changes you suggested:
Result:
http://www.xyz.com/script/index.php http://www.xyz.com/script/index.php
I will understand the global issue.
After making the changes you suggested:
Result:
http://www.xyz.com/script/index.php http://www.xyz.com/script/index.php
Ok, so if you want strictly the directory, then use a variant on your original
..add the ending slash
Code: Select all
$site['homeurl']= "http://{$_SERVER['HTTP_HOST']}" . dirname($_SERVER['SCRIPT_NAME']);Code: Select all
$site['homeurl']= "http://{$_SERVER['HTTP_HOST']}" . dirname($_SERVER['SCRIPT_NAME']) . '/';bdlang, thanks that worked!
Now a newbie question on my original issue so I can hopefully understand if you do not mind.
Why would my first test suing the following format add an extra leading http:// ?
$site[homeurl] = ("http://".$HTTP_HOST."".dirname($SCRIPT_NAME));
Result:
http:// http://www.xyz.com/script
When this one does not even show a leading http://
Second Test:
$site[homeurl] = ($HTTP_HOST."".dirname($SCRIPT_NAME));
Result:
test.xyz.com/script
Thanks,
Bob
Now a newbie question on my original issue so I can hopefully understand if you do not mind.
Why would my first test suing the following format add an extra leading http:// ?
$site[homeurl] = ("http://".$HTTP_HOST."".dirname($SCRIPT_NAME));
Result:
http:// http://www.xyz.com/script
When this one does not even show a leading http://
Second Test:
$site[homeurl] = ($HTTP_HOST."".dirname($SCRIPT_NAME));
Result:
test.xyz.com/script
Thanks,
Bob