How to control Apache URL to filename translation via PHP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chung Leong

    How to control Apache URL to filename translation via PHP?

    Here's a problem I'm trying to solve:

    In the configuration page of our CMS there is place where the administrator
    would specify the directory where uploaded audio files will be stored. The
    page currently does not work as fully as I would like. After a change the
    audio files are not web-accessible until httpd.conf is updated to map URLs
    to the new folder (and an Apache restart).

    In my httpd.conf there's a line that looks like the following:

    RewriteRule ^/audio/(.*) C:/Audio/$1

    So it seems if I can somehow make the "C:/Audio" part a variable that can be
    modified by PHP, my problem would be solved.

    Any idea?


    P.S. Don't suggest using readfile(), fpassthru(), etc.


  • Brion Vibber

    #2
    Re: How to control Apache URL to filename translation via PHP?

    Chung Leong wrote:[color=blue]
    > In my httpd.conf there's a line that looks like the following:
    >
    > RewriteRule ^/audio/(.*) C:/Audio/$1
    >
    > So it seems if I can somehow make the "C:/Audio" part a variable that can be
    > modified by PHP, my problem would be solved.[/color]

    You can configure Apache to use an external program as a filter for
    rewrite rules; a PHP command-line script could probably do the job.

    See:


    -- brion vibber (brion @ pobox.com)

    Comment

    • Chung Leong

      #3
      Re: How to control Apache URL to filename translation via PHP?


      "Brion Vibber" <brion@pobox.co m> wrote in message
      news:2nqgd7F3ku gbU1@uni-berlin.de...[color=blue]
      > Chung Leong wrote:[color=green]
      > > In my httpd.conf there's a line that looks like the following:
      > >
      > > RewriteRule ^/audio/(.*) C:/Audio/$1
      > >
      > > So it seems if I can somehow make the "C:/Audio" part a variable that[/color][/color]
      can be[color=blue][color=green]
      > > modified by PHP, my problem would be solved.[/color]
      >
      > You can configure Apache to use an external program as a filter for
      > rewrite rules; a PHP command-line script could probably do the job.
      >
      > See:
      > http://httpd.apache.org/docs/mod/mod...tml#RewriteMap
      >
      > -- brion vibber (brion @ pobox.com)[/color]

      A static RewriteMap seems to work well enough. Thanks for the suggestion!


      Comment

      Working...