|Internal Redirect triggered by mod cgi|
Local redirects are internal
| 4:50 pm on Apr 8, 2011 (gmt 0)|
I'm seeing a weird behaviour:
when I print http headers to go for a local redirect without adding an HTTP Status that indicates a redirect, the redirect is done internally by apache.
Let's say I have a perl script named test.pl and a file test.htm which are accessable via /test.pl and /test.htm.
If test.pl contains
print "Status: 307\nLocation: /test.htm\n\n";
everything works as you'd guess, the browser gets a redirect, follows it and fetches test.htm
If test.pl contains
print "Location: /test.htm\n\n";
The browser does _NOT_ get a redirect, but rather gets the response as if it had requested test.htm without any indication that an internal redirect happened.
There's nothing else going on, no mod_rewrite or anything. if you replace test.htm with another script and have them both edit a file, you'll see that both are executed.
Can anybody tell me which module / directive is responsible?
It's not really a problem, I was just surprised when I didn't see a redirect reflected in the address bar when I looked through an old script.
| 11:49 pm on Apr 14, 2011 (gmt 0)|
You're missing the protocol and domain name on both code snippets, and therefore all bets are off...
Try including full URLs in that Location header, and see if that changes anything.
Also, be sure to delete your browser cache before testing any change to server-side code. Otherwise, your browser is going to show you cached pages and server response codes. Either delete the cache before each test of new code, or disable it entirely by setting it size or lifetime to zero (as appropriate to your browser). Don't forget to turn it back on when done, though!
| 12:05 am on Apr 15, 2011 (gmt 0)|
The Live HTTP Headers extension for Firefox may also prove useful in seeing the HTTP transaction between browser and server.
| 12:19 pm on Apr 15, 2011 (gmt 0)|
jdMorgan: You're right, I forgot to mention: with absolute URLs the server returns the redirect to the client. It's only the local URI without a Redirect Status header.
I've seen this on two servers, but I haven't really investigated myself, which I might have to if nobody knows the answer ;)
I've watched it with Live HTTP Headers and even Wireshark since I thought it might be a bug in firefox, but it's not.
As I said, it's not a big deal, I was just curious "who" in the request cycle is responsible for it.