Re: RewriteMap PRG By Example Using C

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

 



Sorry,

Let me explain my situation again.
I'm using directive RewriteMap using external rewriting program.
This program is developed in language C.

When I require a page in the browser is shown an error (Bad Request 400).

My program in C to rewriting URL

#include <stdio.h>
  int main() {
  int id = 0;
    fscanf(stdin, "%d", &id);
    switch(id) {
       case 111: fprintf(stdout, "/index.html");  break;
       case 222: fprintf(stdout, "/new.html");  break;
       case 333: fprintf(stdout, "/teste.php?var=4/8"); break;
    }
   
    fflush(stdout);
    return 0;
}

My httpd.conf is:

  RewriteEngine on
  RewriteLock /usr/local/apache2/logs/file.lock
  RewriteMap prgmap prg:/usr/local/apache2/file
  RewriteRule ^/(.*) ${prgmap:$1}


My rewritelog:

[localhost/sid#8b4cd68][rid#8ce45a0/initial] (2) init rewrite engine with requested uri /111
[localhost/sid#8b4cd68][rid#8ce45a0/initial] (3) applying pattern '^/(.*)' to uri '/111'
[localhost/sid#8b4cd68][rid#8ce45a0/initial] (5) map lookup OK: map=prgmap key=111 -> val=
[localhost/sid#8b4cd68][rid#8ce45a0/initial] (2) rewrite '/111' -> ''
[localhost/sid#8b4cd68][rid#8ce45a0/initial] (2) local path result:

Why is this error ??

I hope have given all information.

Ricardo



#include <stdio.h>
  int main() {
  int id = 0;
>>>>  fscanf(stdin, "%d", &id);
>>>>  switch(id) {
>>>>    case 1: fprintf(stdout, "/index.html");
>>>>    break;
>>>>
>>>>    case 2: fprintf(stdout, "/new.html");
>>>>    break;
>>>>
>>>>    case 3: fprintf(stdout, "/teste.php?var=4/8");
>>>>    break;
>>>>  }
>>>>  fflush(stdout);
>>>>  return 0;
>>>> }
>>>
>>> You need to loop and you probably need to read up until a newline.
>>>
>>>>
>>>> My httpd.conf:
>>>>  RewriteEngine on
>>>>  RewriteLock /usr/local/apache2/logs/file.lock
>>>>  RewriteMap prgmap prg:/usr/local/apache2/file
>>>>  RewriteRule ^/(.*) ${prgmap:$1}
>>>>
>>>> My program in C called file
>>>> In my folder htdocs I have three files (index.html, new.html and
>>>> test.php).
>>>> When typed in the browser "http//localhost/1" I think that URL is mapped
>>>> to
>>>> address "http://localhost/index.html"
>>>>
>>>> What happen ?? Is test right ??
>>>
>>> I don't know, what happened?
>>>
>>> --
>>> Eric Covener
>>> covener@xxxxxxxxx
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/RewriteMap-PRG-By-Example-Using-C-tp23283305p23296344.html
> Sent from the Apache HTTP Server - Users mailing list archive at Nabble.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@xxxxxxxxxxxxxxxx
>   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>

Just FYI, that's a horrible way to get help. Most people on this list
don't have the patience to deal with somebody who sounds frantic.

Eric already answered your question. If it's still not working, you
need to provide more details, like what you did, what you got, how you
know it's not correct.

-Brian


--
Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from: http://keys.gnupg.net

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




--
Muito Obrigado

Ricardo

[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