Simple redirect that is not working.... :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rocky70304
Forum Newbie
Posts: 5
Joined: Wed Jul 02, 2008 10:47 pm

Simple redirect that is not working.... :(

Post by Rocky70304 »

I am new to PHP code (just starting a website), however I have wrote generic object oriented code before which is similar. I wrote a simple redirect code to redirect my main site http://www.StreetLegalTech.com to a sub directory http://www.StreetLegalTech.com/LTXLSX , I have to have this redirect until I get my main page up and running (which will be awhile) anyways my code is pasted below, but when i pull the page up it gives me the following error :
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in D:\Hosting\3074294\html\default.php on line 2

Parse error: syntax error, unexpected T_STRING in D:\Hosting\3074294\html\default.php on line 2
I have thought about this for hours and can't come up with any thing wrong with this code, if anyone can help I would greatly appreciate it.
Thanks,

Code saved as default.php, also have tried saving it as index.php:

<?php
header("http/1.1 301 Moved Permanently");
header("location: http://www.streetlegaltech.com/ltxlsx/");
exit();
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Simple redirect that is not working.... :(

Post by Christopher »

Not sure if this will help, but I think it is supposed to be:

Code: Select all

header("HTTP/1.1 301 Moved Permanently");
(#10850)
Rocky70304
Forum Newbie
Posts: 5
Joined: Wed Jul 02, 2008 10:47 pm

Re: Simple redirect that is not working.... :(

Post by Rocky70304 »

Tried doing that, tried all kinds of upper and lower case options, but can't seem to get that error to go away. urghhh
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Simple redirect that is not working.... :(

Post by John Cartwright »

Theres no parse error in that code, thats for sure. Are you sure you are updating the correct file?
Bon Bon
Forum Commoner
Posts: 66
Joined: Sat Mar 13, 2004 10:21 pm
Location: UK

Re: Simple redirect that is not working.... :(

Post by Bon Bon »

Try:

Code: Select all

<?php
header('Location: http://www.streetlegaltech.com/ltxlsx/', TRUE, 301);
exit;
?>
Copy and paste the full lot into your PHP page overwriting everything you posted in your initial post. If you have anything before it please post that so we can work out if anything else is causing a problem.
Rocky70304
Forum Newbie
Posts: 5
Joined: Wed Jul 02, 2008 10:47 pm

Re: Simple redirect that is not working.... :(

Post by Rocky70304 »

Tried that code, gave me the same error. To be on the safe side, I completely deleted the file from my server and re-ftp'd the file with the new code, same error. That is the only code in the whole file, just the simple redirect, it's not making any sense to me.
Rocky70304
Forum Newbie
Posts: 5
Joined: Wed Jul 02, 2008 10:47 pm

Re: Simple redirect that is not working.... :(

Post by Rocky70304 »

FYI, my server's PHP version is 5.x, don't know if that has anything to do with it, but just want to make sure that is out there.
Rocky70304
Forum Newbie
Posts: 5
Joined: Wed Jul 02, 2008 10:47 pm

Re: Simple redirect that is not working.... :(

Post by Rocky70304 »

Solved the problem, just thought I would post this in case others run accross this. I tried uploading the file with godaddy.com's file manager, i tried using an ftp client, and also made a network connection to ftp the file, all gave this error. However, tonight I wrote the redirect in a blank file using godaddy's file manager and saved it there and it works great now. Don't have a clue why that makes a difference, but apparently it does. :)
Post Reply