homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

301 Redirect with PHP and google.

5+ Year Member

Msg#: 3614723 posted 2:51 pm on Mar 30, 2008 (gmt 0)

Newbie here....

I want to redirect some old pages from my old site to my new site... I do not wanna use modrewrite. So, i used PHP and I am gonna put the above code on my HEADER include file.

Is this how it is done using PHP? and would the search engines see that the page is being redirected with a 301? would this signal to search engine to remove the old INDEXED page url and replace it with the new url?

$arrivingUrl = getenv('REQUEST_URI');
if (substr($arrivingUrl, 0, 7) == "/crafts"){
if ($arrivingUrl == "/crafts.html")
header("Location: http://example.com/artsandcrafts.html", true, 301);
if ($arrivingUrl == "/crafts/scrapbooking.html")
header("Location: http://example.com/artsandcrafts/papercraft.html", true, 301);
header("Location: http://example.com", true, 301);

[edited by: dreamcatcher at 6:26 pm (utc) on Mar. 30, 2008]
[edit reason] Use example.com, thanks. [/edit]



WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 3614723 posted 4:50 pm on Mar 30, 2008 (gmt 0)

it is something like that, but check the actual "Location" syntax against the PHP manual to be sure.

And yes, it would signal to re-index the new URL and de-index the old one.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved