Forum Moderators: coopster

Message Too Old, No Replies

301 Redirect

         

Dexie

8:16 am on Dec 17, 2004 (gmt 0)

10+ Year Member



Hi,

I've got 8 filenames, within the same domain, that have changed, and I need to do 301's in my .htaccess from the old files to the new files.

I've managed to come across this code below, but how do I specify the old filename and the new filename please?

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: [domain...]
header("Connection: close");
?>

Any help appreciated.

Sev.

Patrick Taylor

8:47 am on Dec 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In your .htaccess:

redirect 301 /oldfile.htm ht*p://www.yoursite.com/newfile.php

Just a separate line like that for each filename being redirected, making sure the old file is written as a relative URL. I've never done this with PHP.

(Obviously, replace the asterisk with a "t".)

Dexie

12:42 pm on Dec 18, 2004 (gmt 0)

10+ Year Member



Hi Patrick,

Many thanks for that.

I'm a little new to this, is it ok to do a 301 with php please?

Especially as far as Mr Google and Mrs Yahoo etc are concerned.

Sev.

jatar_k

8:57 pm on Dec 18, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> is it ok to do a 301 with php please

yes, as long as it is a permanent move then that is the appropriate code to use.

more codes here
[w3.org...]

Patrick Taylor

12:10 am on Dec 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm a little new to this

Me too. I understood the standard redirect method was with .htaccess. Perhaps someone more knowledgeable would be able to outline the pros and cons. Sorry I can't be more expansive.

Dexie

8:31 am on Dec 19, 2004 (gmt 0)

10+ Year Member



Many thanks to you both, problem solved.

Sev.