affpro1234 Posted June 17, 2008 Share Posted June 17, 2008 I have converted a database from one script i have to be used for another script. The url stucture of both scripts is different and I need to create a 301 redirect script to run on the new site to send the old linked pages to the new url structured pages. The new converted database holds the new urls in it and I can call them using an article id number which is the same number included at the end of the old url (ie http://www.sitename.com/Articles/title-of-article/1234) I am trying to extract the number from the old url, but am having difficulty...very newbie here. here is the code that I have so far: function getInfo(){ $url = rtrim($_SERVER['REQUEST_URI'], '/'); $urlParts = explode('/', $url); $lastPart = end($urlParts); } $articles = $this->getArticles("article_id = ".intval(getInfo()),'',1); $article = $articles[0]; header("Status: 301 Moved Permanently", false, 301); header("Location: $article->url"); exit; All comments and any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
btherl Posted June 17, 2008 Share Posted June 17, 2008 You're missing only one thing: function getInfo(){ $url = rtrim($_SERVER['REQUEST_URI'], '/'); $urlParts = explode('/', $url); $lastPart = end($urlParts); return $lastPart; } Quote Link to comment Share on other sites More sharing options...
affpro1234 Posted June 17, 2008 Author Share Posted June 17, 2008 thanks that solved it!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.