My PHP redirects don't work: 404 Error

Status
Not open for further replies.

hookshot

New member
Apr 28, 2008
90
1
0
I've done a number of google searches and still can't find the answer to this, so I'm hoping the WF community can help.

Every time I try to do a PHP redirect, I get an error 404 when I go to the page. I tried restarting smartFTP to see if that was the problem, and I tried it on two different domains. My hosting is with dreamhost. This was the code I was using:
Code:
<?php header( 'Location: http://www.google.ca' ) ;?>

Any help would be appreciated, thanks!
 


That should work. It works for me.

Code:
<?php
header( 'Location: http://www.yoursite.com/new_page.html' ) ;
?>

1. Two things:
Change the code on the redirect page to be simply this. You need to replace the URL above with the URL you wish to direct to.

2. Be sure that you do not have any text sent to the browser before this, or it will not work. Your safest bet is to simply remove all content from the page but the redirect code.


You could also do a 100% reliable javascript redirect but that's not what you asked for. If you want to go the javascript route, send me a PM or let me know and I'll post it here.

Thanks,
Matt
 
I could be wrong, but I think it's the spaces that are fucking it up.

Probably should look like:

Code:
<?php
header('Location: http://www.google.ca');
?>
 
if you took out the php code and just stuck in random text and uploaded it do you still get the 404 or does it show the text? if you still get the 404 then you're entering the url wrong. your php code is correct btw and if that was problem it wouldn't return a 404.
 
Yeah, I've tried the text with the way Davros put it and it still doesn't work... I know I don't have the URL wrong (it's just test.php) and random text doesn't work either.

I guess it must be a hosting problem, I'll have to contact DreamHost about it. Thanks for the help!
 
I could be wrong, but I think it's the spaces that are fucking it up.

PHP ignores whitespace, so that couldn't be the problem. I would bet it is a misconfiguration of your php.ini settings. Contact your host.
 
Status
Not open for further replies.