Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
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.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
 
Register now for full access!
Old 04-07-2008, 01:53 AM Re: 301 redirects in PHP
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
It will work if you don't do any output before these strings.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
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: 310
Trades: 0
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.
dman_2007 is offline
Reply With Quote
View Public Profile
 
Old 04-07-2008, 03:36 PM Re: 301 redirects in PHP
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Thanks both, that is exactly what I needed to know.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to 301 redirects in PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.86265 seconds with 12 queries