Solved

Does LOCATION: http://  Work?

Posted on 1997-11-12
6
153 Views
Last Modified: 2013-12-25
I am using the following line in my CGI-PERL code:

print "Location: http://mywebsite.com/test.htm\n\n";

This is the ONLY line I have that outputs back to browser.  From what I've gathered, this should tell the browser to switch to this new web site (mywebsite.com/test.htm).  Unfortunately it doesn't do this.  

All I get is DOCUMENT CONTAINS NO DATA (or something to that extent) by Netscape 4.0 and down and MS Explorer.

Any clues as to what I'm doing wrong?
0
Comment
Question by:jujoo
  • 3
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
Perhaps the http://mywebsite.com/test.htm document contains no data?
Or perhaps some other line in your program is preventing the only output line from printing.
0
 
LVL 3

Accepted Solution

by:
gwalters earned 0 total points
Comment Utility
One more newline ought to do it (an HTTP header is delimited by a blank line).

BTW, I hope you're planning on increasing the points before grading this.
0
 
LVL 6

Expert Comment

by:alamo
Comment Utility
Funny, looks like there's a blank line after the Location header to me...

jujoo, if you run the script from the commasd line what does it print? That might tell you something.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:gwalters
Comment Utility
Oops, I didn't look closely enough.  Now that I have, I see the real problem.  Try printing this:


"Location: http://mywebsite.com/test.htm\r\n\r\n"



You MUST use CR LF at the end of lines in HTTP.


0
 
LVL 6

Expert Comment

by:alamo
Comment Utility
Must? I have never used \r\n and have seen only a handful of examples which do, almost everything I've seen uses just \n. I've never had a problem. (The server is repsonsible for parsing the headers anyway). Is this server-dependent?
0
 
LVL 3

Expert Comment

by:gwalters
Comment Utility
OK, "must" (especially with my all-caps emphasis) might have been a bit strong.  I meant it was in the HTTP spec as CR LF.

I beleive most servers see the LF coming in from a CGI and convert them to CR LF.

Could we get a URL to check so we can stop guessing here (and I can stop making bold statements that turn out to be wrong ;)


0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now