Change content based on url`s

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Wunderkid
Forum Newbie
Posts: 1
Joined: Thu Feb 21, 2013 7:43 am

Change content based on url`s

Post by Wunderkid »

Hello!
I`m newbie and just started with php. Could you help me?
I want to change text based on many url.
I write code, but it filtering only one url :(

Code: Select all

<?php
$ref=getenv('HTTP_REFERER');
if (strpos($ref,"www.site.com/news")>0) 
{
echo "News;

}
else
{
echo "";
};
?>  
I want to make something like that

Code: Select all

<?php
$ref=getenv('HTTP_REFERER');
if (strpos($ref,"www.site.com/1")>0) 
{
echo "1;

}
else
{

if (strpos($ref,"www.site.com/2")>0) 
{
echo "2;

}
else
{

if (strpos($ref,"www.site.com/3")>0) 
{
echo "3;

}
else
{

?>  
Hope you will help me...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Change content based on url`s

Post by Christopher »

It looks like you are using mod_rewrite. Take a look at the value in $_SERVER['PATH_INFO'].
(#10850)
Post Reply