[mod_rewrite] stdin gets lost in rewritten PUT request

Discussion in 'Apache' started by fritemayo, Jul 7, 2011.

  1. #1
    Hello all,

    We have an API hosted on Amazon's servers (hence no control over httpd.conf), and I use mod_rewrite to translate calls in (what I believe is) a customary way.

    All I use is one .htaccess file located in the top directory, that contains:

    RewriteCond %{REQUEST_FILENAME} !^(.+)\.php$
    RewriteRule ^([^/]+)/(.*)$	$1/handler.php?$2      [L,QSA]
    
    Code (markup):
    The idea is:
    - to have several versions of the API in directories located in the root directory
    - to direct all API calls to a single entry point, aka handler.php

    Problem: while everything works as expected with GET and POST requests, in the case of a PUT request the handler script is unable to retrieve the request data.

    If I issue a PUT request to, for instance my.api.host/v1/accounts/acc_id, then it is correctly rewritten into my.api.host/v1/handler.php?accounts/acc_id, but handler.php waits for incoming data on the php://input stream and eventually times out.

    I believe URL-rewriting has something to do with the problem, as a direct PUT request to my.api.host/v1/handler.php works fine, i.e. the script does read the request data as expected.

    It looks like nothing much for a savvy Apache user... but me, it has me baffled :confused:
    I'd immensely appreciate any sort of nudge that would get me out of this rut, and out of trouble at the same time because I kind of committed myself to getting it working, unaware as I was :-(

    Thanks a lot.
     
    fritemayo, Jul 7, 2011 IP
  2. fritemayo

    fritemayo Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Problem lied within the client code... I'm happy nobody wasted any of their time trying to help, I would have ended up with egg all over my face :)
     
    fritemayo, Jul 8, 2011 IP
  3. yusuyi

    yusuyi Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you could write a file named .htaccess at the v1 DIR and write some codes here:
    RewriteEngine on
    RewriteBase /v1/
    RewriteRule ^(.*)\.html$ handler.php?c=/$1
     
    yusuyi, Jul 9, 2011 IP
  4. yusuyi

    yusuyi Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    your rule has something wrong

    my.api.host/v1/handler.php will be rewrited to my.api.host/v1/handler.php
     
    yusuyi, Jul 9, 2011 IP