r_mehmed has asked for the wisdom of the Perl Monks concerning the following question:

monks, is redirection with netscape different to that with IE? I've succeeded redirecting with IE fine, but netscape keeps throwing '404 Not Found' errors! This is the code:
print $q->redirect( "\Admin" );
'\Admin' is a folder with its root set to a static HTML file 'index.html'. I'm running WinNT, and I guess the slashes would make difference under Unix, have tried most combinations...browsed through old posts in perlmonks.org, but with no apparent luck! Thanks r_mehmed novice

Replies are listed 'Best First'.
Re: Netscape Redirection
by theorbtwo (Prior) on Jan 18, 2003 at 23:34 UTC

    You do want slashes, and not backslashes. What matters here isn't the path conventions of your native platform. HTML is supposted to be immune to such things. What matters is the conventions of URIs, and those use slashes. IE will clean up this bad HTML for you and guess at what you actualy meant to say, Netscape won't. (I consider this somthing netscape does right. It's arguable that IE does it right, and NS gets it wrong. In any case, the correct answer is to use slashes.)

    Also, backslashes have special meaning in double-quotes -- they make the next character be interpreted as "special". (They escape into a magical world. The two-character sequence is thus caled an escape sequence.) Try print "\Admin" from the command-line; you'll notice that it prints Admin, not \Admin. If you were using warnings (and why aren't you, and strict too?), you'd get a "Unrecognized escape \A passed through", because it doesn't recognize "\A" as a valid escape, and assumes you meant A.

    Use "\\Admin" ("\\" is an escape sequence for a plain backslash), or '\Admin' (backslashes aren't special (most of the time) in single quotes).

    This is explained in perlop, under "quotelike operators".


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      Thanks for your help! I've sorted it out now. The initial problem wasn't actually in the redirection script but the form itself! I had it all in backslashes.Cheers r_mehmed novice
Re: Netscape Redirection
by abatkin (Sexton) on Jan 19, 2003 at 07:24 UTC
    Actually, what you want is to redirect to the absolute URI (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30). So that would mean that you will need something that looks like "http://www.somehost.com/path/to/Admin/"...Basically it should be everything that would otherwise be typed into the browser's location bar.
Re: Netscape Redirection
by Flame (Deacon) on Jan 19, 2003 at 05:21 UTC
    It's also likely you'll need the full path (should always include that just in case anyway).



    My code doesn't have bugs, it just develops random features.

    Flame ~ Lead Programmer: GMS | GMS

Re: Netscape Redirection
by bart (Canon) on Jan 19, 2003 at 22:23 UTC
    I'm with theorbtwo on this one. Netscape is more strict on its requirements than MSIE — which isn't a bad thing, quite the contrary — and the official standard for URLs says you need to use slashes, not backslashes, for your path separator. See the last line on page 3 of RFC1738 — Uniform Resource Locators (URL), and I quote:
    Some URL schemes (such as the ftp, http, and file schemes) contain names that can be considered hierarchical; the components of the hierarchy are separated by "/".

    MSIE never should never have accepted your redirection URL. You code line should read:

    print $q->redirect( "/Admin" );
    Make sure the case is correct, too.