httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.Lance Wilkinson" <>
Subject [users@httpd] Rewrite confusion
Date Thu, 27 Oct 2011 19:22:58 GMT
I have a set of RewriteRule directives in an Apache HTTPD v2.2.6 on a Solaris 
10 zone which work just fine to take any incoming URI


and cause that to execute a perl script, /robotz/

where a ScriptAlias defines the /robotz directory, outside my document root tree.

The rewrites work just fine, every time /robots.txt is requested, the output of
/robotz/ is returned.

I have the SAME configuration of ServerAlias and RewriteRule directives being 
used on a Red Hat Linux box with Apache HTTPD v2.2.3, and the resultant 
rewrites according to the rewrite log file show the document root being 
prepended to the rewritten pattern, causing the request to be for
<documentRoot>/robotz/, which of course does not exist.

I'm assuming from the outset that I have something missing in my RewriteRule
directives...  not something where the directory definition for the directory
resolved from ScriptAlias is not physically resident inside the appropriate 
VirtualHost (so it's available to ALL VirtualHosts defined).

Here's a snippet of the rewrite.log file:

(2) init rewrite engine with requested uri /robotz/
(3) applying pattern '^/robots.txt$' to uri '/robotz/'
(3) applying pattern '^/(.*)' to uri '/robotz/'
(4) RewriteCond: input=''
	 pattern='!^secureappsdev\.libraries\.psu\.edu' [NC] => not-matched
(1) pass through /robotz/

	Well, that works just fine.  Specified the final path and rewrites
	basically skipped past it.  Script runs and presents expected output.

(2) init rewrite engine with requested uri /robots.txt
(3) applying pattern '^/robots.txt$' to uri '/robots.txt'
(2) rewrite '/robots.txt' ->
(3) reduce ->
(2) remember /robotz/ to have MIME-type 'application/x-httpd-cgi'
(2) local path result: /robotz/
(2) prefixed with document_root to /dlt/webservers/cf9/htdocs/robotz/
(1) go-ahead with /dlt/webservers/cf9/htdocs/robotz/ [OK]
(1) force filename /dlt/webservers/cf9/htdocs/robotz to have MIME-type

	But this ultimately results in a 404 since there's no "robotz"
	directory in the document root tree under htdocs.  It's PARALLEL
	to the htdocs directory, in fact.

And here are (all of) my rewrite directives ("\" to wrap, not really in the
configuration file though...):

RewriteEngine On
RewriteLogLevel 9
RewriteLog logs/secureappsdev-rewrite.log
RewriteRule ^/robots.txt$  \  \
RewriteCond %{SERVER_NAME}   !^secureappsdev\.libraries\.psu\.edu [NC]
RewriteCond %{SERVER_NAME}   !=""
RewriteCond %{HTTP_HOST}   !^secureappsdev\.libraries\.psu\.edu [NC]
RewriteCond %{HTTP_HOST}   !=""
RewriteRule ^/(.*)$1 [L,R=301]

They're all in a VirtualHost definition <VirtualHost \>

The VH stanza contains not only these Rewrite directives, but also contains
         ScriptAlias /robotz/ "/dlt/webservers/cf9/robots/"

The <Directory "/dlt/webservers/cf9/robots/"></Directory> stanza is
EXTERNAL to the VH stanza, just like it is on the Solaris configuration where
all this works.


J.Lance Wilkinson ("Lance")		InterNet:
Systems Design Specialist - Lead	Phone: (814) 865-4870
Digital Library Technologies		FAX:   (814) 863-3560
E3 Paterno Library
Penn State University
University Park, PA 16802

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message