Page 1 of 1

How do I make a redirect?

Posted: Wed Mar 01, 2006 9:47 am
by ~sikka~
I need a redirect from http://www.norskstabbursmat.no to http://www.norskstabbursmat.no/kurv/
can anyone tell me how to do this?

Posted: Wed Mar 01, 2006 9:59 am
by feyd
.htaccess (with mod_rewrite) or using php's header() function.

Posted: Wed Mar 01, 2006 10:02 am
by ~sikka~
ehh ok... I wish I could do that - can you spell it out for me?

Posted: Wed Mar 01, 2006 10:04 am
by Gambler

Code: Select all

header("Location: www.norskstabbursmat.no/kurv/");

Posted: Wed Mar 01, 2006 10:07 am
by feyd
remember to use a full URL.. http:// and all.

Posted: Wed Mar 01, 2006 10:15 am
by ~sikka~
ok I went to my index.php file and in the header I put this code:

Code: Select all

<?php header("Location: http://www.norskstabbursmat.no/kurv/");?>
And I got this error msg:
Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/nstab/norskstabbursmat.no/index.php:10) in /hsphere/local/home/nstab/norskstabbursmat.no/index.php on line 25

Posted: Wed Mar 01, 2006 10:23 am
by feyd
the redirection must happen before any output is sent to the requesting agent.

Read here: viewtopic.php?t=1157

Posted: Wed Mar 01, 2006 10:27 am
by ~sikka~
I dont understand - I even get the error msg if I have my php-file containing only that string tho.

Posted: Wed Mar 01, 2006 10:32 am
by feyd
you likely have a space or something before. These errors can easily happen between inclusions where you may have a trailing space or leading space (possibly a carriage return.)

Posted: Wed Mar 01, 2006 10:41 am
by ~sikka~
Thank you! It was ONE space before my code :roll:
But now its working! :mrgreen: :mrgreen: