Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

using strpos for redirects

Links for php scripts

Moderators: macek, egami, gesf

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") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 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=http://www.domain.com/new-bio-page">

<?php } ?>


Is there a better way to do this?
lukeh1980
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Jun 03, 2011 11:12 am

Return to PHP Scripts

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.