httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Christensen <dpchr...@holgerdanske.com>
Subject [users@httpd] Apache 2.2 URL Rewriting Guide From Static to Dynamic 404 Not Found script not found or unable to stat: redirect:/printenv.pl
Date Sun, 20 Feb 2011 06:40:43 GMT
Apache users:

I'm trying to learn how to use the Apache rewrite module to redirect 
incoming hits for virtual *.html pages to Perl CGI scripts using the 
information provided in the Apache 2.2 manual "URL Rewriting Guide" 
chapter "From Static to Dynamic" section:

 
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html#static-to-dynamic


For my first test, I am attempting to have hits for the page:

     http://bluefish.holgerdanske.com/printenv.html

invoke the script at URL:

     http://bluefish.holgerdanske.com/printenv.pl

which resides in file:

     /home/dpchrist/bluefish/public_html/printenv.pl


When I invoke the script via its direct URL, everything works:

     http://bluefish.holgerdanske.com/printenv.pl


But when I request the URL that is supposed to be rewritten:

     http://bluefish.holgerdanske.com/printenv.html

I see:

     404 Not Found

and the Apache error log says:

     script not found or unable to stat: redirect:/printenv.pl


Also, I have attempted to enable the rewrite log and set the target 
directory mode to 0777, but no log file is written (?).


Please see console session, below.


Any suggestions?


TIA,

David



2011-02-19 22:18:15 dpchrist@p43400e ~/bluefish
$ cat /etc/debian_version
6.0



2011-02-19 21:18:20 dpchrist@p43400e ~/bluefish
$ sudo apache2ctl -V
Server version: Apache/2.2.16 (Debian)
Server built:   Jan  1 2011 21:57:31
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.4.2, APR-Util 1.3.9
Compiled using: APR 1.4.2, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Worker
   threaded:     yes (fixed thread count)
     forked:     yes (variable process count)
Server compiled with....
  -D APACHE_MPM_DIR="server/mpm/worker"
  -D APR_HAS_SENDFILE
  -D APR_HAS_MMAP
  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
  -D APR_USE_SYSVSEM_SERIALIZE
  -D APR_USE_PTHREAD_SERIALIZE
  -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
  -D APR_HAS_OTHER_CHILD
  -D AP_HAVE_RELIABLE_PIPED_LOGS
  -D DYNAMIC_MODULE_LIMIT=128
  -D HTTPD_ROOT="/etc/apache2"
  -D SUEXEC_BIN="/usr/lib/apache2/suexec"
  -D DEFAULT_PIDLOG="/var/run/apache2.pid"
  -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
  -D DEFAULT_ERRORLOG="logs/error_log"
  -D AP_TYPES_CONFIG_FILE="mime.types"
  -D SERVER_CONFIG_FILE="apache2.conf"



2011-02-19 21:18:23 dpchrist@p43400e ~/bluefish
$ cat /etc/apache2/apache2.conf | grep '.' | egrep -v '^#'
LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
     StartServers          5
     MinSpareServers       5
     MaxSpareServers      10
     MaxClients          150
     MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
     StartServers          2
     MinSpareThreads      25
     MaxSpareThreads      75
     ThreadLimit          64
     ThreadsPerChild      25
     MaxClients          150
     MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_event_module>
     StartServers          2
     MaxClients          150
     MinSpareThreads      25
     MaxSpareThreads      75
     ThreadLimit          64
     ThreadsPerChild      25
     MaxRequestsPerChild   0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
     Order allow,deny
     Deny from all
     Satisfy all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include httpd.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" 
\"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" 
combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include conf.d/
Include sites-enabled/



2011-02-19 21:25:14 dpchrist@p43400e ~/bluefish
$ l -w 64 /etc/apache2/mods-enabled/
./		       autoindex.conf@	mime.load@
../		       autoindex.load@	negotiation.conf@
alias.conf@	       cgid.conf@	negotiation.load@
alias.load@	       cgid.load@	reqtimeout.conf@
auth_basic.load@       deflate.conf@	reqtimeout.load@
authn_file.load@       deflate.load@	rewrite.load@
authz_default.load@    dir.conf@	setenvif.conf@
authz_groupfile.load@  dir.load@	setenvif.load@
authz_host.load@       env.load@	status.conf@
authz_user.load@       mime.conf@	status.load@



2011-02-19 21:54:51 dpchrist@p43400e ~/bluefish
$ cat /etc/apache2/sites-enabled/bluefish.holgerdanske.com
# $Id: bluefish.holgerdanske.com,v 1.5 2011-02-20 05:54:48 dpchrist Exp $
<VirtualHost *:80>
     ServerName   bluefish.holgerdanske.com
     DocumentRoot           /home/dpchrist/bluefish/public_html
     RewriteLog             /home/dpchrist/bluefish/log/rewrite.log
     ScriptAlias  /cgi-bin/ /home/dpchrist/bluefish/cgi-bin/
</VirtualHost>



2011-02-19 21:54:59 dpchrist@p43400e ~/bluefish
$ sudo apache2ctl configtest
Syntax OK



2011-02-19 21:55:05 dpchrist@p43400e ~/bluefish
$ sudo apache2ctl graceful



2011-02-19 21:55:46 dpchrist@p43400e ~/bluefish
$ l -w 64 public_html/
./   .htaccess	favicon.png  madewithbluefish-w3cstyle1.png
../  CVS/	index.html   printenv.pl@



2011-02-19 21:57:14 dpchrist@p43400e ~/bluefish
$ cat public_html/.htaccess
# $Id: .htaccess,v 1.2 2011-02-20 05:47:55 dpchrist Exp $
Options +ExecCGI
AddHandler cgi-script pl
RewriteEngine  on
RewriteBase    /
RewriteRule    ^printenv\.html$  printenv.pl  [H=cgi-script]



2011-02-19 21:59:48 dpchrist@p43400e ~/bluefish
$ cat public_html/printenv.pl
#! /usr/bin/perl
# $Id: printenv.pl,v 1.3 2011-02-20 05:47:55 dpchrist Exp $
print "Content-Type: text/plain\n\n";
foreach my $k (sort keys %ENV) {
     print $k, ' ', $ENV{$k}, "\n";
}



2011-02-19 22:00:41 dpchrist@p43400e ~/bluefish
$ wget -O - http://bluefish.holgerdanske.com/printenv.pl
--2011-02-19 22:01:00--  http://bluefish.holgerdanske.com/printenv.pl
Resolving bluefish.holgerdanske.com... 192.168.0.34
Connecting to bluefish.holgerdanske.com|192.168.0.34|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: `STDOUT'

     [<=>                                    ] 0           --.-K/s 
         DOCUMENT_ROOT /home/dpchrist/bluefish/public_html
GATEWAY_INTERFACE CGI/1.1
HTTP_ACCEPT */*
HTTP_CONNECTION Keep-Alive
HTTP_HOST bluefish.holgerdanske.com
HTTP_USER_AGENT Wget/1.12 (linux-gnu)
PATH 
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
QUERY_STRING
REMOTE_ADDR 192.168.0.34
REMOTE_PORT 55402
REQUEST_METHOD GET
REQUEST_URI /printenv.pl
SCRIPT_FILENAME /home/dpchrist/bluefish/public_html/printenv.pl
SCRIPT_NAME /printenv.pl
SERVER_ADDR 192.168.0.34
SERVER_ADMIN [no address given]
SERVER_NAME bluefish.holgerdanske.com
SERVER_PORT 80
SERVER_PROTOCOL HTTP/1.0
SERVER_SIGNATURE <address>Apache/2.2.16 (Debian) Server at 
bluefish.holgerdanske.com Port 80</address>

SERVER_SOFTWARE Apache/2.2.16 (Debian)
TZ America/Los_Angeles
     [ <=>                                   ] 765         --.-K/s   in 
0s

2011-02-19 22:01:00 (61.2 MB/s) - written to stdout [765]



2011-02-19 22:01:00 dpchrist@p43400e ~/bluefish
$ wget -O - http://bluefish.holgerdanske.com/printenv.html
--2011-02-19 22:01:14--  http://bluefish.holgerdanske.com/printenv.html
Resolving bluefish.holgerdanske.com... 192.168.0.34
Connecting to bluefish.holgerdanske.com|192.168.0.34|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2011-02-19 22:01:14 ERROR 404: Not Found.



2011-02-19 22:01:14 dpchrist@p43400e ~/bluefish
$ sudo tail -n 3 /var/log/apache2/error.log
[Sat Feb 19 22:00:41 2011] [notice] SIGUSR1 received.  Doing graceful 
restart
[Sat Feb 19 22:00:41 2011] [notice] Apache/2.2.16 (Debian) configured -- 
resuming normal operations
[Sat Feb 19 22:01:14 2011] [error] [client 192.168.0.34] script not 
found or unable to stat: redirect:/printenv.pl



2011-02-19 22:31:26 dpchrist@p43400e ~/bluefish
$ ll -d ~/.
drwxr-xr-x 53 dpchrist dpchrist 4096 Feb 19 21:54 /home/dpchrist/./



2011-02-19 22:34:37 dpchrist@p43400e ~/bluefish
$ ll -d ~/bluefish/
drwxr-xr-x 7 dpchrist dpchrist 4096 Feb 19 22:25 /home/dpchrist/bluefish//



2011-02-19 22:34:44 dpchrist@p43400e ~/bluefish
$ ll -d ~/bluefish/log
drwxrwxrwx 3 dpchrist dpchrist 4096 Feb 19 22:31 
/home/dpchrist/bluefish/log/



2011-02-19 22:34:47 dpchrist@p43400e ~/bluefish
$ l log/
./  ../  .cvsignore  .exists  CVS/

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message