This is a discussion on mod_rewrite woes within the Linux Web Servers forums, part of the Web Server and Related Forums category; Apache 1.3.31, just upgraded from .27 with the same problem, Red Hat 8.0. I'm using RewriteMap ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Apache 1.3.31, just upgraded from .27 with the same problem, Red Hat 8.0.
I'm using RewriteMap prg:/path/to/program to execute a perl script. Is there any normal situation under which Apache 1.3.31 (Red Hat 8.0) mod_rewrite actually won't load a program specified by the RewriteMap directive? My httpd.conf consists of the following mod_rewrite directives... Module rewrite_module modules/mod_rewrite.so AddModule mod_rewrite.c RewriteEngine on RewriteOptions inherit RewriteLock /var/run/httpd/RewriteLock RewriteMap prj prg:/var/www/offline/osi.justthe.net/project-map.pl The virtualhost entry for the site in question: <VirtualHost 66.35.75.157> ServerName osi.justthe.net ServerAlias www.osi.justthe.net DocumentRoot /var/www/virtual_hosts/osi.justthe.net <Directory /var/www/virtual_hosts/osi.justthe.net/> AllowOverride all </Directory> ServerAdmin webmaster@justthe.net RewriteLogLevel 9 ErrorLog /var/log/httpd/osi.justthe.net-error_log TransferLog /var/log/httpd/osi.justthe.net-access_log RewriteLog /var/log/httpd/osi.justthe.net-rewrite_log </VirtualHost> (yes, I know AllowOverride all is a bad idea, but it's only there for debugging purposes right now) The .htaccess file in the root directory of the site: RewriteEngine on RewriteBase / RewriteRule ^$ index.php [L] RewriteRule ^browse.jtn$ index.php?page=browse [L] RewriteRule ^search.jtn$ index.php?page=search [L] RewriteRule ^latest.jtn$ index.php?page=latest [L] RewriteRule ^contact.jtn$ index.php?page=contact [L] RewriteRule ^support.jtn$ index.php?page=support [L] RewriteRule ^_(.*)$ ${prj:$1}.jtn [R,L] There are a few more lines, but that last one is the relevant one; a test entry that's supposed to redirect, for example, /_testing to /_testing.jtn (right now, the Perl script just takes input from stdin and spits it back out) #!/usr/bin/perl $|=1; open(FILE,">>/tmp/redirect.out"); print FILE "Apache loaded me"; close(FILE); while (<STDIN>) { print $_; } Instead of getting directed to {original_URI}.jtn, I just get directed to http://osi.justthe.net/.jtn. The reason I set up the rule as a redirect is so I could take a look at the address bar in my web browser and see if I was getting the right page. A previous version of this script wrote to a logfile in /tmp, every time it got something on stdin. This worked when I was running the script from the commandline, but nothing happened when the script was (supposedly) loaded by Apache. Log file entries for a random test (http://osi.justthe.net/_asd): 66.35.75.157 - - [02/Jun/2004:01:35:23 -0400] [osi.justthe.net/sid#817a88 c][rid#81d6d3c/initial] (3) [per-dir /var/www/virtual_hosts/osi.justthe.n et/] applying pattern '^_(.*)$' to uri '_asd' 66.35.75.157 - - [02/Jun/2004:01:35:23 -0400] [osi.justthe.net/sid#817a88 c][rid#81d6d3c/initial] (2) [per-dir /var/www/virtual_hosts/osi.justthe.n et/] rewrite _asd -> .jtn The crappy thing is that now that I have 1.3.31, it doesn't even display the FAILED message that 1.3.27 did when it tried to do the mapping. At least with 1.3.27 I could tell that the rule was at least being reached and executed. (And I upgraded to .31 due to mod_rewrite bugs in .27... bah...) Any ideas about why the script is not running? A free beer goes to the first person who can solve this problem. In all other aspects, mod_rewrite is working just fine. -- JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/ "someone once called me a sofa, but i didn't feel compelled to rush out and buy slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003 |
|
|||
|
Steven J Sobol <sjsobol@justthe.net> wrote:
> Apache 1.3.31, just upgraded from .27 with the same problem, Red Hat 8.0. > > I'm using RewriteMap prg:/path/to/program to execute a perl script. Footnote: RewriteMap doesn't work with a text file either... -- JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/ "someone once called me a sofa, but i didn't feel compelled to rush out and buy slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003 |
|
|||
|
Steven J Sobol <sjsobol@justthe.net> wrote:
> Steven J Sobol <sjsobol@justthe.net> wrote: >> Apache 1.3.31, just upgraded from .27 with the same problem, Red Hat 8.0. >> >> I'm using RewriteMap prg:/path/to/program to execute a perl script. > > Footnote: RewriteMap doesn't work with a text file either... Further to my two posts... everything works, including a RewriteMap using either the 'prg' or 'txt' map types, when the directives are in the virtualhost entry for the site. Just not when they're in .htaccess. Anyone know whether this is a bug or intended behavior? -- JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/ "someone once called me a sofa, but i didn't feel compelled to rush out and buy slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003 |
|
|||
|
On Wed, 02 Jun 2004 16:27:45 -0500, Steven J Sobol
<sjsobol@JustThe.net> wrote: >Steven J Sobol <sjsobol@justthe.net> wrote: >> Steven J Sobol <sjsobol@justthe.net> wrote: >>> Apache 1.3.31, just upgraded from .27 with the same problem, Red Hat 8.0. >>> >>> I'm using RewriteMap prg:/path/to/program to execute a perl script. >> >> Footnote: RewriteMap doesn't work with a text file either... > >Further to my two posts... everything works, including a RewriteMap using >either the 'prg' or 'txt' map types, when the directives are in the >virtualhost entry for the site. Just not when they're in .htaccess. > >Anyone know whether this is a bug or intended behavior? It's been a while so I can't remember the specifics, but I remember that mod_rewrite works a little differently when in .htaccess due to how Apache deals with .htaccess. Check the mod_rewrite documentation; the RewriteBase directive in particular might be of interest. Regards, -Claire |
|
|||
|
Claire Tucker <fake@invalid.com> wrote:
> It's been a while so I can't remember the specifics, but I remember > that mod_rewrite works a little differently when in .htaccess due to > how Apache deals with .htaccess. > > Check the mod_rewrite documentation; the RewriteBase directive in > particular might be of interest. Hm, I used RewriteBase / when putting the directives in .htaccess. The problem remains that the map programs weren't loaded - they ran fine once I moved the RewriteMap directives to the virtualhost entry IF the RewriteRule directives were also there, but not if the RewriteRule directives were in ..htaccess. -- JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/ "someone once called me a sofa, but i didn't feel compelled to rush out and buy slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003 |
|
|||
|
Steven J Sobol <sjsobol@justthe.net> wrote:
> Claire Tucker <fake@invalid.com> wrote: > >> It's been a while so I can't remember the specifics, but I remember >> that mod_rewrite works a little differently when in .htaccess due to >> how Apache deals with .htaccess. >> >> Check the mod_rewrite documentation; the RewriteBase directive in >> particular might be of interest. > > Hm, I used RewriteBase / when putting the directives in .htaccess. > The problem remains that the map programs weren't loaded - they ran fine once > I moved the RewriteMap directives to the virtualhost entry IF the RewriteRule > directives were also there, but not if the RewriteRule directives were in > .htaccess. actually, the map program *is* loaded now that I have the RewriteMap directive in the virtualhost entry, but it will only be *executed* if the rule referring to it is also in the vh entry. Perhaps it's a scope issue, which would really kinda suck, because I'd prefer to not have to restart my web server every time I change a rule. (Which I obviously would have to do if the rules are in the vh entry.) But for now I'll live with doing everything in the vh entry. However, if someone could come up with a way to make the maps work in .htaccess, *please* let me know. -- JustThe.net Internet & New Media Services, Apple Valley, CA PGP: 0xE3AE35ED Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / sjsobol@JustThe.net Domain Names, $9.95/yr, 24x7 service: http://DomainNames.JustThe.net/ "someone once called me a sofa, but i didn't feel compelled to rush out and buy slip covers." -adam brower * Hiroshima '45, Chernobyl '86, Windows 98/2000/2003 |