You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Eric Covener <co...@gmail.com> on 2010/06/29 22:36:40 UTC

Re: [users@httpd] RewriteRule failing on windows when changing content-handlers

> [Tue Jun 29 15:45:20 2010] [error] [client 127.0.0.1] script
> 'redirect:/oxfordv2/page.php' not found or unable to stat

Two big clues in this message.

mod_rewrite is meant to revisit this rewritten URL in its "handler"
hook, but some other handler a) got there first and b) thought it was
supposed to handle the request (via some type of config).

That handler is probably mod_cgid/mod_cgi/mod_fastcgi/mod_php.
Perhaps removing the throwback  "AddType" will be a step in the right
direction.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


Re: [users@httpd] RewriteRule failing when changing content-handlers

Posted by Eric Covener <co...@gmail.com>.
> Out of curiosity, any idea why this would work in a VirtualHost container
> but not in the per-dir .htaccess file? My only problem with this arrangement
> is that I'd need to restart apache when I make changes at that high of a
> level. Dropping in a .htaccess file is much more preferable.

when it happens in vhost context, rewrite happens in an early phase of
apache processing.
when it happens in per-dir context, it happens in a late phase and
causes the request to be restarted after the substituion.

so there are lots of opportunities for them to work differently.
99%of the time the per-vhost one is more intuitive / easier to deal
with.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


[users@httpd] RewriteRule failing when changing content-handlers

Posted by Greg Neujahr <ap...@foxfilter.foxpaws.net>.
Hey Eric,

Thanks for the quick reply and hopefully a step in the right 
direction. I tested it on my linux box as well, and it's apparently a 
common thing between the two of 'em, so whatever it is I'm doing (if 
it's supposed to work) is something I've made a habbit of doing. I'd 
like to fix that.

At your suggestion, I removed the AddType lines and replaced them 
with some recommendations I found via a google search. The new bit in 
the httpd.conf file is:

<IfModule php5_module>
     PHPIniDir "d:/php"
     AddType text/html .php .phps
     AddHandler application/x-httpd-php .php
     AddHandler application/x-httpd-php-source .phps
</IfModule>

I've also tried it without the enclosed AddType part you see above, 
but the problem seems to still persist whether or not it's present. I 
also fiddled a bit using the <FilesMatch> directive (as suggested by 
the PHP install pages) and it still exhibited the same problem.

mod_cgi was enabled, but I disabled that and the problem still 
happens. I also tried disabling script-alias lines, in the off-chance 
they had some special functionality that was taking control of the 
process. I looked through the list of enabled modules and didn't find 
anything that seemed like it would be an issue, and nothing else you 
mentioned was enabled at the time.

Out of curiosity, any idea why this would work in a VirtualHost 
container but not in the per-dir .htaccess file? My only problem with 
this arrangement is that I'd need to restart apache when I make 
changes at that high of a level. Dropping in a .htaccess file is much 
more preferable.

Also, just to eliminate PHP as a potential issue here, I tried using 
a rewrite rule to change any file with the .bogus extension to .html, 
and then set the handler to text/html (or text/plain). I even moved 
the .htaccess and the test.html file into the root web directory, 
just in case there was some issue. The .htaccess file was:

RewriteEngine On
RewriteRule (.*)\.bogus $1.html [H=text/html]

The error log spilled out the following:

[Tue Jun 29 17:35:31 2010] [error] [client 127.0.0.1] File does not 
exist: redirect:/test.html

If I remove the [H=text/html] part from the rule, it reads the file 
just fine. At least here, the error message seems a little more 
informative. Looks like it can't locate the file for some reason. I'm 
sure the file test.html is in there, so I'm not sure precisely what 
file it's trying to locate. Here's a copy of the rewrite.log when it 
fails and then when it works (without the handler rewrite). It does 
seem that when it fails there are no entries for the internal 
redirect and when it works, there are entries that indicate it's 
being processed further.

Fails
-----
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (3) [perdir 
E:/cyg/wwwroot/] strip per-dir prefix: E:/cyg/wwwroot/test.bogus -> test.bogus
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (3) [perdir 
E:/cyg/wwwroot/] applying pattern '(.*\.php)s$' to uri 'test.bogus'
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (3) [perdir 
E:/cyg/wwwroot/] strip per-dir prefix: E:/cyg/wwwroot/test.bogus -> test.bogus
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (3) [perdir 
E:/cyg/wwwroot/] applying pattern '(.*)\.bogus' to uri 'test.bogus'
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (2) [perdir 
E:/cyg/wwwroot/] rewrite 'test.bogus' -> 'test.html'
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (3) [perdir 
E:/cyg/wwwroot/] add per-dir prefix: test.html -> E:/cyg/wwwroot/test.html
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (2) [perdir 
E:/cyg/wwwroot/] remember E:/cyg/wwwroot/test.html to have 
Content-handler 'text/html'
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (2) [perdir 
E:/cyg/wwwroot/] strip document_root prefix: E:/cyg/wwwroot/test.html 
-> /test.html
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (1) [perdir 
E:/cyg/wwwroot/] internal redirect with /test.html [INTERNAL REDIRECT]
127.0.0.1 - - [29/Jun/2010:17:35:31 --0400] 
[dev.domain.com/sid#176bb40][rid#17841a0/initial] (1) force filename 
redirect:/test.html to have the Content-handler 'text/html'

Works
-----
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17901d0/initial] (3) [perdir 
E:/cyg/wwwroot/] strip per-dir prefix: E:/cyg/wwwroot/test.bogus -> test.bogus
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17901d0/initial] (3) [perdir 
E:/cyg/wwwroot/] applying pattern '(.*)\.bogus' to uri 'test.bogus'
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17901d0/initial] (2) [perdir 
E:/cyg/wwwroot/] rewrite 'test.bogus' -> 'test.html'
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17901d0/initial] (3) [perdir 
E:/cyg/wwwroot/] add per-dir prefix: test.html -> E:/cyg/wwwroot/test.html
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17901d0/initial] (2) [perdir 
E:/cyg/wwwroot/] strip document_root prefix: E:/cyg/wwwroot/test.html 
-> /test.html
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17901d0/initial] (1) [perdir 
E:/cyg/wwwroot/] internal redirect with /test.html [INTERNAL REDIRECT]
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17de4c8/initial/redir#1] (3) [perdir 
E:/cyg/wwwroot/] strip per-dir prefix: E:/cyg/wwwroot/test.html -> test.html
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17de4c8/initial/redir#1] (3) [perdir 
E:/cyg/wwwroot/] applying pattern '(.*)\.bogus' to uri 'test.html'
127.0.0.1 - - [29/Jun/2010:17:35:49 --0400] 
[dev.domain.com/sid#176bb40][rid#17de4c8/initial/redir#1] (1) [perdir 
E:/cyg/wwwroot/] pass through E:/cyg/wwwroot/test.html

Thanks again to anyone who has more thoughts on the matter. I'll be 
glad to test out specific options and configurations if you like, or 
if you need to see a full set of configs for the given server, I can 
provide those as well.

- Greg


---------------------------------------------------------------------
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