A typical FAQ about URL rewriting is how to redirect failing requests on webserver A to webserver B. Usually this is done via ErrorDocument CGI-scripts in Perl, but there is also a mod_rewrite solution. But notice that this performs more poorly than using an ErrorDocument CGI-script!
Place this in your httpd.conf og .htaccess file on the domain you want to redirect HTTP requests from
Solution
This is one possible solution but less flexible, and is less error safe
RewriteEngine on
RewriteCond /your/docroot/%{REQUEST_FILENAME} !-f
RewriteRule ^(.+) http://webserverB.dom/$1
The problem here is that this will only work for pages inside the DocumentRoot.
Tags: apache2, mod_rewrite, redirect, RewriteCond, RewriteEngine, RewriteRule
Posted by Hans-Henry Jakobsen
Q. I need to run a program called oraMon.pl. However this program is run from cron job. It report error to stderr and normal output to stdout. How do I save stdout, stderr and both into 3 separate log files?
A. It is not that hard if you know howto redirect stderr, stdout and a small command called tee.
=> fd0 is stdin
=> fd1 is stdout
=> fd2 is stderr
There are two formats for redirecting standard output and standard error:
&>word
and
>&word
For example anything written to fd2 to the same place as output to fd1, you will use:
2>&1
tee command read from standard input and write to standard output and file.
So to send stderr to /tmp/errors.log, stdout to /tmp/output.log and both to /tmp/final.log, type as follows:
((/path/to/oraMon.pl 2>&1 1>&3 | tee /tmp/errors.log) 3>&1 1>&2 | tee /tmp/output.log) > /tmp/final.log 2>&1
Read bash man page and tee command for more information.
Tags: redirect, stderr, stdout
Posted by Hans-Henry Jakobsen
The first part, “> /dev/null” means send standard output to the ‘bit bucket” or in other words, throw it away.
The second part, “2>&1” means “redirect standard error (2) to the same place as standard outout (1.)
Tags: redirect, stderr, stdout
Posted by Hans-Henry Jakobsen