SRL Archive - Web Development

Redirecting problem


Infantry001

2007-02-20 22:29:56

I upload this php script to my subdomain "infscripts.freehostia.com":

<?php
header( 'Location: http://Infantry.freehostia.com/InfHome.htm' ) ;
exit;
?>

to redirect to http://Infantry.freehostia.com/InfHome.htm . But whenever i go to infscripts.freehostia.com, all i see is the index/parent directory. Can anyone help me out?

P.S. Yes im a total noob at php :P

TOB

2007-02-20 22:59:32

Hmm that should work fine, be sure you named it index.php though(if you are trying to redirect from the subdomain.

moparisthebest

2007-02-21 00:12:27

You have to name it index.php, not redirect.php

Infantry001

2007-02-21 15:55:54

oooo alright thanks

SubiN

2007-02-22 23:57:31

so is it working now?

munk

2007-07-25 01:14:07

i know this is a php forum, and "header" will work fine for what your trying to do, but if youve written anything to the file before you use "header" it will give you an error and exit the script. so for redirecting i always use Javascript. It's alot more versatile for it. things like:

<script type=text/javascript>
window.location.replace('whatever.html');
</script>
^that will redirect the page and not let the user press the back button. Works great for $_POST vars so they wont press back and get the "This Page Has Expired" message.

also it has Frames support, so you can redirect any frame from a different frame within the frameset….if that makes sense?

just for future knowledge