using strpos for redirects

Links for php scripts

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 2
Joined: Fri Jun 03, 2011 11:12 am

using strpos for redirects

Postby lukeh1980 » Fri Feb 03, 2012 11:39 am

Hi, I have recently migrated a wordpress site to joomla and there are a few bio links that I would like redirected. These have wordpress id's like ?id=1, ?id=13, ?id=18 etc. I was trying to have a php script that examines the url and if it contains one of those id it will redirect to the new bio page. The problem is that since it's true that the url contains ?id=1 as well as part of ?id=18 then the page gets redirected to ?id=1's bio. Is there an alternate way I can do this?

My code is below:

Code: Select all

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 } else {
 return $pageURL;
$URL = curPageURL();

$biopage = '/firm-overview/meet-our-team/?id=18';

And the if statement:

Code: Select all

<?php if(strpos($URL,$biopage) !== false) { ?>

<meta http-equiv="REFRESH" content="0; url=">

<?php } ?>

Is there a better way to do this?

Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 3 guests