PDA

View Full Version : redirect



themoose
October 31st, 2005, 11:19
Hi,
i need a redirect code that DOES NOT need any part to be placed in between the <head> tags, works in a php file and can be delayed to 2 seconds.
Thanks,
themoose

p.s. i have tried;


<?php
header("Location: http://www.example.com/");
?>
but it does not work :(.

p.p.s. it has to be able to work at the bottom of the page.

R4g1ng
November 1st, 2005, 06:18
<meta http-equiv='refresh'
content='0;url=http://example.com'>
I use plain old that if header redirection doesn't work. And you don't need it in the head tags.

themoose
November 1st, 2005, 10:40
<meta http-equiv='refresh'
content='0;url=http://example.com'>
I use plain old that if header redirection doesn't work. And you don't need it in the head tags.

are you sure you dont need it in the header tags? Well, anyway, i managed to get round it by echoing a JS one. Thanks anyway :P

ryza
November 2nd, 2005, 03:39
change
<meta http-equiv='refresh' content='0;url=http://example.com'>
to
<meta http-equiv='refresh' content='2;url=http://example.com'>

can place it anywhere..

RangerOfFire
November 2nd, 2005, 09:43
Header needs to be sent before any html code.

Use meta redirects, not JS as people can have JS disabled.

Tree
November 2nd, 2005, 18:17
i need a redirect code that DOES NOT need any part to be placed in between the <head> tags

Correct me if I'm wrong, but don't meta redirects (or any meta information for that matter) belong in between <head> tags?

RangerOfFire
November 3rd, 2005, 04:11
Strictly, yes. They still work outside head tags though.

ryza
November 3rd, 2005, 20:43
Correct me if I'm wrong, but don't meta redirects (or any meta information for that matter) belong in between <head> tags?

That is a standard not a requirement, If you are adding meta information for search engines you would follow a standard to make sure they get the relevant information, but for general stuff like this you can do it your own way.
Even with todays advanced search technology I doubt the spiders would even require the information to be in head tags & it wont cause any visual errors.

R4g1ng
November 4th, 2005, 06:21
Why change it to a 2? Sorry, I just don't see the point. XD

RangerOfFire
November 4th, 2005, 12:31
The OP wanted it to wait 2 seconds.

themoose
November 4th, 2005, 13:52
Why change it to a 2? Sorry, I just don't see the point. XD


cuz google get confused if its less

robert allen
November 5th, 2005, 05:07
Is there a way to make a php file write to .htaccess?

themoose
November 5th, 2005, 12:05
Is there a way to make a php file write to .htaccess?

what the ---- does that have to do with anything?

ryza
November 5th, 2005, 21:48
Is there a way to make a php file write to .htaccess?


<?php
$handle=fopen(".htaccess", "w");
fwrite($handle, "TEXT TO PUT IN FILE");
fclose($handle);
?>

http://php.mirrors.ilisys.com.au/manual/en/function.fopen.php

themoose
November 6th, 2005, 06:45
you need to CHMOD .htaccess 666 though.

robert allen
November 6th, 2005, 06:53
You can use .htaccess to do a pernament redirect so that it does not use any meta or anything. It will be interesting if someone can do this. You need some fields and some varibles first.

like

$site
$random

and then

<?php
$handle=fopen(".htaccess", "w");
fwrite($handle, "RedirectMatch temp ^/'$random'$ '$site'");
fclose($handle);
?>

Or something like that...

Can anyone help me?

themoose
November 6th, 2005, 06:55
my script (which i fixed ages ago, y is this topic still alive??) needs to run first, then redirect.

robert allen
November 6th, 2005, 08:22
No, but this script will totally pwn your script if someone could create it, i am not really that good at php!

Death001
November 6th, 2005, 08:43
No, but this script will totally pwn your script if someone could create it, i am not really that good at php!


your not really that good at anything, but i was looking for a .htacces redirection script and i found one when i searched google