httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.Lance Wilkinson" <jl...@psu.edu>
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

		/robots.txt

and cause that to execute a perl script, /robotz/robots.pl

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/robots.pl 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/robots.pl, 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/robots.pl
(3) applying pattern '^/robots.txt$' to uri '/robotz/robots.pl'
(3) applying pattern '^/(.*)' to uri '/robotz/robots.pl'
(4) RewriteCond: input='secureappsdev.libraries.psu.edu'
	 pattern='!^secureappsdev\.libraries\.psu\.edu' [NC] => not-matched
(1) pass through /robotz/robots.pl

	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' ->
	'https://secureappsdev.libraries.psu.edu/robotz/robots.pl'
(3) reduce https://secureappsdev.libraries.psu.edu/robotz/robots.pl ->
	/robotz/robots.pl
(2) remember /robotz/robots.pl to have MIME-type 'application/x-httpd-cgi'
(2) local path result: /robotz/robots.pl
(2) prefixed with document_root to /dlt/webservers/cf9/htdocs/robotz/robots.pl
(1) go-ahead with /dlt/webservers/cf9/htdocs/robotz/robots.pl [OK]
(1) force filename /dlt/webservers/cf9/htdocs/robotz to have MIME-type
	'application/x-httpd-cgi'

	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$  \
      	https://secureappsdev.libraries.psu.edu/robotz/robots.pl  \
		[L,T=application/x-httpd-cgi]
RewriteCond %{SERVER_NAME}   !^secureappsdev\.libraries\.psu\.edu [NC]
RewriteCond %{SERVER_NAME}   !=""
RewriteCond %{HTTP_HOST}   !^secureappsdev\.libraries\.psu\.edu [NC]
RewriteCond %{HTTP_HOST}   !=""
RewriteRule ^/(.*) https://secureappsdev.libraries.psu.edu/$1 [L,R=301]


They're all in a VirtualHost definition <VirtualHost \	
				secureappsdev.libraries.psu.edu:443>

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.


	Thoughts?

-- 
J.Lance Wilkinson ("Lance")		InterNet: Lance.Wilkinson@psu.edu
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: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