$_GET empty with Apache and content negotiation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dalyian39@gmail.com

    #1

    $_GET empty with Apache and content negotiation

    Hello,

    I'm pretty new to PHP but I have a page, B.php, which runs fine, but I
    want to be able to call this as B (long story), i.e.
    http://mysite/B?foo=bar should be equivalent to calling
    http://mysite/B.php?foo=bar.

    I've tried creating a symlink on the filesystem B -> B.php but that
    just sends the text content of the B.php file itself back to the
    caller. (I kind of thought I'd get away with that =) )

    My config is Red Hat 9.0 with the included Apache 2.0.40. PHP seems to
    built in to the core instead of as a module because it just works and
    there's no included module in httpd.conf.

    What I've done now is to try the type-map approach from the docs at
    http://httpd.apache.org/docs/2.0/con...gotiation.html and added a
    file called B.var with contents

    URI: B

    URI: B.php
    Content-type: application/php

    Now the call to http://mysite/B?foo=bar works, and the PHP executes,
    but the variable $_GET is empty whereas it is not when I execute
    http://mysite/B.php?foo=bar.

    Undoubtedly it's something to do with mime types or something.

    Any thoughts, or suggestions?

    Thanks
    Ian

  • Colin McKinnon

    #2
    Re: $_GET empty with Apache and content negotiation

    dalyian39@gmail .com wrote:
    [color=blue]
    > Hello,
    >
    > I'm pretty new to PHP but I have a page, B.php, which runs fine, but I
    > want to be able to call this as B (long story), i.e.
    > http://mysite/B?foo=bar should be equivalent to calling
    > http://mysite/B.php?foo=bar.
    >
    > I've tried creating a symlink on the filesystem B -> B.php but that[/color]
    <snip>[color=blue]
    > What I've done now is to try the type-map approach from the docs at[/color]
    <snip>[color=blue]
    >
    > Any thoughts, or suggestions?[/color]

    I'd start again using mod_rewrite.

    C.

    Comment

    • dalyian39@gmail.com

      #3
      Re: $_GET empty with Apache and content negotiation

      You're right - I compiled Apache (with mod_rewrite) and PHP from source
      and used

      RewriteEngine on
      RewriteRule ^B?$ /B.php

      in .htaccess. Works great. Incidentally there's a bug which convinced
      me that using MultiViews was almost pointless -
      http://bugs.php.net/bug.php?id=28023.

      Ian

      Comment

      • John Dunlop

        #4
        Re: $_GET empty with Apache and content negotiation

        dalyian39 wrote:
        [color=blue]
        > I'm pretty new to PHP but I have a page, B.php, which runs fine, but I
        > want to be able to call this as B (long story),[/color]

        you're right, it is a long story, but it's not yours alone.

        I don't see why you would put .php in your URLs anyway.
        [color=blue]
        > i.e.
        > http://mysite/B?foo=bar should be equivalent to calling
        > http://mysite/B.php?foo=bar.[/color]

        I would stick with your content negotiation, even if you have only one
        representation at the moment, but switch to MultiViews instead.

        --
        Jock

        Comment

        Working...