tilmes
asked on
shows text only in main domain
Hello,
i need to show texts only at main home page like www.abcd.com, not at www.abcd.com/something/
This info will be inserted in index.php.
How can i do this?
i need to show texts only at main home page like www.abcd.com, not at www.abcd.com/something/
This info will be inserted in index.php.
How can i do this?
ASKER
Hi Oliver,
would you please complete the code, which i can use it directly in script? like this kind of,
if ($sitename=abcd.com
{
print "here is text";
}
would you please complete the code, which i can use it directly in script? like this kind of,
if ($sitename=abcd.com
{
print "here is text";
}
Putting 2 and 2 together...
if ($_SERVER['SERVER_NAME' == 'abcd.com') {
print "here is text";
}
if ($_SERVER['SERVER_NAME' == 'abcd.com') {
print "here is text";
}
ASKER
I get an error with this code.
ASKER
if ($_SERVER['SERVER_NAME' == 'abcd.com']) {
print "here is text";
}
I used both www.abcd.com and abcd.com
but it do not print anything.
print "here is text";
}
I used both www.abcd.com and abcd.com
but it do not print anything.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thankns Squinky,
it works.
it works.
ASKER
Hi Squinky,
there is an problem. The text shows also in second level of directories. It should not show in directory like abcd.com/test/
or abcd.com/text.html
I must show only under abcd.com
there is an problem. The text shows also in second level of directories. It should not show in directory like abcd.com/test/
or abcd.com/text.html
I must show only under abcd.com
It's only showing because you're telling it to. If you don't want to display it, just don't include that code in files below the root level.
ASKER
The code must be included in file, It must be in index.php
The text must not show under other directories.
The text must not show under other directories.
OK, in that case look at the parse_url() function - if the path is "/", print the stuff, otherwise don't:
http://www.php.net/manual/en/function.parse-url.php
$pi = parse_url($_SERVER['REQUES T_URI']);
if ($_SERVER['SERVER_NAME'] == 'abcd.com' and $pi['path'] == '/') {
print "here is text";
}
If it doesn't work, read the docs some more.
http://www.php.net/manual/en/function.parse-url.php
$pi = parse_url($_SERVER['REQUES
if ($_SERVER['SERVER_NAME'] == 'abcd.com' and $pi['path'] == '/') {
print "here is text";
}
If it doesn't work, read the docs some more.
ASKER
Hi Squinky,
it works fine now. Thanks.
Would you help me with perl for same work?
I have posted new quetion.
it works fine now. Thanks.
Would you help me with perl for same work?
I have posted new quetion.
$_SERVER['PHP_SELF'] holds the scrip name (incl. path)