Reply
301 redirects in PHP
Old 04-06-2008, 09:26 PM 301 redirects in PHP
wayfarer07's Avatar
Insomniac

Posts: 487
Name: Abel Mohler
Location: Asheville, North Carolina USA
I have a client that I am helping orient into a new design, and rewriting his entire site. In the process, we changed the names of several pages to better reflect site content. Unfortunately we then discovered that his host did not have .htaccess support, although it is an Apache site.

I did some research, and came up with this:
PHP Code:
<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.somacon.com/");
exit();
?>
Is there anything I need to know about using this method, and will it work exactly like doing a 301 redirect via .htaccess?

This is a very important question for this particular website, as the site gets a significant amount of traffic from Google, and we don't want it to be affected negatively.

Thank you in advance.
__________________
Go FREELANCE <=====||=====> Hire Me
wayfarer07 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-07-2008, 01:53 AM Re: 301 redirects in PHP
mtishetsky's Avatar
Super Spam Talker

Posts: 865
Location: Volendam, Netherlands
It will work if you don't do any output before these strings.
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 04-07-2008, 03:10 AM Re: 301 redirects in PHP
Ultra Talker

Posts: 308
Yes, it will work exactly like 301 redirect via .htaccess. Here's another way to do it :

Code:
 <?php
    header('Location: http://www.example.com', true, 301);
 ?>

Also, make sure you do this for each page you have renamed.
__________________
tiny url
dman_2007 is offline
Reply With Quote
View Public Profile Visit dman_2007's homepage!
 
Old 04-07-2008, 03:36 PM Re: 301 redirects in PHP
wayfarer07's Avatar
Insomniac

Posts: 487
Name: Abel Mohler
Location: Asheville, North Carolina USA
Thanks both, that is exactly what I needed to know.
__________________
Go FREELANCE <=====||=====> Hire Me
wayfarer07 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to 301 redirects in PHP
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12055 seconds with 13 queries