RE: ENV variables and custom 404 error page
Bryan Harris wrote: # do this. make sure that this line is the # ONLY thing you print out to the browser. print Location: http://rightplace.com/\n\n;; Wow, this is cool! Where is this documented? I'm interested in learning about other things like this... This is part of the HTTP spec, which is defined in RFC 2616: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 The CGI module can produce a redirect header as well, with its redirect() method. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ENV variables and custom 404 error page
Bryan Harris wrote: # do this. make sure that this line is the # ONLY thing you print out to the browser. print Location: http://rightplace.com/\n\n;; Wow, this is cool! Where is this documented? I'm interested in learning about other things like this... This is part of the HTTP spec, which is defined in RFC 2616: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30 The CGI module can produce a redirect header as well, with its redirect() method. Thanks, Bill and Bob, I'll look into all of them... - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
ENV variables and custom 404 error page
I have a custom 404 error page that uses that shows the URL of the page that couldn't be found using var=REDIRECT_URL. Is there a way to take this variable, such as /folder/wrong.html, strip out everything except folder, match folder and redirect (launch the web page) to folder/index.html. Any assistance or links would be appreciated. - Do you Yahoo!? Get better spam protection with Yahoo! Mail
Re: ENV variables and custom 404 error page
I have a custom 404 error page that uses that shows the URL of the page that couldn't be found using var=REDIRECT_URL. Is there a way to take this variable, such as /folder/wrong.html, strip out everything except folder, match folder and redirect (launch the web page) to folder/index.html. Depends. Three different ways to do it: * if you just want to redirect the user to the right place (without showing an interim page), then don't use Perl at all - look into your server (presumably Apache) capability. The following, in your httpd.conf or .htaccess file, will do the same thing, only without the additional Perl/CGI overhead: Redirect /folder/wrong.html /folder/index.html * if you want to show an error page first, use a meta-refresh tag to automatically send the user to the right place. The following example would tell the user's browser to go the the rightplace.com after ten seconds. For accessibility, be sure to make this a clickable link somewhere on the page. META HTTP-EQUIV=Refresh CONTENT=10; URL=http://rightplace.com/; * if you just want to redirect the user to the right page, only with your Perl/CGI script, do the following INSTEAD of a Content-type header: # instead of this: print Content-type: text/html\n\n; print Oopsies! Wrong page!; # do this. make sure that this line is the # ONLY thing you print out to the browser. print Location: http://rightplace.com/\n\n;; As for splitting up a URL into its component parts, look into the URI (pseudo code, not tested): my $url = YOUR URL HERE; my $urih = URI-new; my $path = $urih-path($url); my @parts = $urih-path_segments($path); my $first_path = $parts[0]; -- Morbus Iff ( i put the demon back in codemonkey ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ Spidering Hacks: http://amazon.com/exec/obidos/ASIN/0596005776/disobeycom icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ENV variables and custom 404 error page
# do this. make sure that this line is the # ONLY thing you print out to the browser. print Location: http://rightplace.com/\n\n;; Wow, this is cool! Where is this documented? I'm interested in learning about other things like this... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ENV variables and custom 404 error page
Bryan Harris wrote: print Location: http://rightplace.com/\n\n;; Wow, this is cool! Where is this documented? I'm interested in learning about other things like this... http://www.google.com/search?hl=enie=UTF-8oe=UTF-8q=Perl+CGI+ApachebtnG=Google+Search 1,720,000 possibilities Try this place first: perldoc perl Then Google Usenet Then maybe http://www.thesitewizard.com/perl/index.shtml HTH; -Bill- __Sx__ http://youve-reached-the.endoftheinternet.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response