Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

301 Redirect with PHP and google.



2:51 pm on Mar 30, 2008 (gmt 0)

5+ Year Member

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]


4:50 pm on Mar 30, 2008 (gmt 0)

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

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.


Featured Threads

Hot Threads This Week

Hot Threads This Month