I have a similar question: OK let me try to make myself clear here.
I have two parts to a website a general side and another part to the site called photography.
Both parts to the site share the same navigation.
For one of the links in the side navigation i have a link called FAQ’s.
Rather then have 2 different faq links shown I want to create a conditional that if your on the general side of the site go to the general faq and if your on the photography side go to the photo faq.
so something like this i think:
if (gen1.php, gen2.php, gen3.php)
{ go to this gen-faq.php page }
else if (photo1.php, photo2.php)
{go to this photo-faq.php page}
Im not sure if this is the way I would even go around doing this. BUT COULD SOME ONE PLEASE HELP ME WITH THIS PROBLEM
if(preg_match('|(photo1.php|photo2.php)|', $_SERVER['REQUEST_URI'])) {
//serve the link for photo-faq.php page
} else {
//serve the link for gen-faq.php page
}
alternatively you could use $_SERVER['‘HTTP_REFERER’] to see which page they came from and redirect accordingly but thats not always reliable.
if(preg_match('|(w-gallery.php|w-services.php)|', $_SERVER['REQUEST_URI'])) {
//serve the link for photo-faq.php page
('w-faq.php')
} else {
//serve the link for gen-faq.php page
('gen-faq.php')
}
Those brackets aren’t under a spell, PHP doesn’t have a clue what to do with them