Jump to content

The Ultimate PHP 301 direct/forwarding thread!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Dan

Dan

    Programmer

  • Members
  • PipPipPipPip
  • 145 posts
If you don't know what a PHP 301 redirect is, you will by the end of this thread! If you need to redirect a page, unfortunately it isn't as simple as using one of the various methods - only the 301 redirect will preserve search engine rankings for the page. It is the most efficient, search engine friendly method for website redirection - the code 301 is interpreted as "moved permanently".

<?

Header( "HTTP/1.1 301 Moved Permanently" ); 

Header( "Location: http://www.new-url.com" ); 

?>


#2
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
I use just the bottom line to forward.


<?php

Header( "Location: http://www.new-url.com" );

?>


I suppose I should add the 301 line.

#3
sarahk

sarahk

    Newbie

  • Members
  • PipPip
  • 18 posts
Yes you should. Otherwise the server doesn't know why the forward is there. 301s are important so you should take the time to add the extra line.

#4
Guest_Kaabi_*

Guest_Kaabi_*
  • Guests
The PHP redirect is so simple, the "ultimate" makes it sound intricate. It's so funny Dan, you've made a lot of "Ultimate 301 redirect" threads, and it's not even that special a function. You make me laugh (in a good way).

#5
Dan

Dan

    Programmer

  • Members
  • PipPipPipPip
  • 145 posts

Kaabi said:

The PHP redirect is so simple, the "ultimate" makes it sound intricate. It's so funny Dan, you've made a lot of "Ultimate 301 redirect" threads, and it's not even that special a function. You make me laugh (in a good way).

I have added them for every language rather than just post one thread in the "general" forum - I think this will make it easier, and more useful for peple who visit the site.

I just used the word "ultimate" as it is the only thread you will need to learn how to do a 301 redirect in that particular language :)

#6
Guest_Fredto_*

Guest_Fredto_*
  • Guests
I use a .htaccess for my redirections.

It's simple to use and I have to edit only one file for an entire folder ;)

#7
Guest_Kaabi_*

Guest_Kaabi_*
  • Guests
Makes sense, and ultimate is an attractive word. Fredto, does an .htaccess redirect preserve search engine rankings? That's a very important thing that a redirect should do.