httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael B Allen <iop...@gmail.com>
Subject [users@httpd] Invoking PHP without .php extension?
Date Thu, 07 Jul 2011 17:54:54 GMT
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-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message