RewriteRule failing when changing content-handlers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux