Hi,

If your Rewrite rule reads something like this

RewriteRule ^api/(.*) api-gateway.php   [L]

Then basically you can extract the last few bit using regular
expression in our case

$urlParts = null;
preg_match('/api\/([^\/]+)\/([0-9]+)*/', $_SERVER['REQUEST_URI'], $urlParts);
$handlerName = count($urlParts) > 1 ? $urlParts[1] : null;
$identifier = count($urlParts) > 2 ? $urlParts[2] : null;

I would strongly suggest that you use Rewrite rules to achieve this.
Allowing arbitary patterns to use the PHP parser could be an issue
from a security standpoint.

I don't this is "disaster" its just a little misconfiguration :)

On Fri, Jul 8, 2011 at 3:54 AM, Michael B Allen <iop...@gmail.com> wrote:
> I want a request like:
>
>  /base/path/to/target?foo=bar
>
> to invoke a particular PHP file for everything under /base.
>
> It seems the usual way (only way?) to do this is with something like:
>
>  AddHandler php5-script .php
>  AddType text/html .php
>  DirectoryIndex index.php
>
> and with directives like:
>
>  Alias /base /path/to/base/html
>
>  <Directory "/path/to/base/html">
>    Options Indexes FollowSymLinks
>    AllowOverride None
>    Order allow,deny
>    Allow from all
>
>    RewriteEngine on
>    RewriteBase /base
>    RewriteCond %{REQUEST_FILENAME} !-f
>    RewriteCond %{REQUEST_FILENAME} !-d
>    RewriteCond %{REQUEST_FILENAME} !-l
>    RewriteRule .* index.php [L]
>  </Directory>
>
> However this is a disaster. The request for
> /base/path/to/target?foo=bar is received inside the PHP script as
> /base/index.php/path/to/target?foo=bar. Now the application has to
> have intimate knowledge of the presence of the extra /index.php
> segment and exclude it from URLs and paths emitted by the application.
> The internal representation doesn't match the reality of the external
> representation.
>
> So my question is, is there a way to directly invoke a preconfigured
> PHP script for everything at / under a certain location without using
> the .php extension in the request path?
>
> Mike
>
> ---------------------------------------------------------------------
> 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-unsubscr...@httpd.apache.org
>   "   from the digest: users-digest-unsubscr...@httpd.apache.org
> For additional commands, e-mail: users-h...@httpd.apache.org
>
>

---------------------------------------------------------------------
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-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to