Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
07-13-2003, 04:25 AM #1
- Join Date
- May 2002
- Hayward, CA
- Thanked 23 Times in 21 Posts
mod_perl: Running XML through PHP preprocessor
Lately I've been revisiting an old thorn in my side for HTTP usage. Namely, how can I pass to PHP, SSI, Perl, or Python (or any other language as needed) an XML document for processing via XML processing instructions?
At first, I tinkered with the idea of creating custom Apache filename extensions (.pxml, for instance, for PHP-processed XML). A little work with .htaccess showed that wouldn't necessarily fit the bill.
So I'm exploring another idea, based on something I remember Firepages telling me.
Suppose I have a URI:
Where the actual file resides at
The "php" directory could be an alias for indicating I should send the document through the PHP interpreter. After it goes through the interpreter, the server would then return the correct mime-type.
Is this doable, perhaps with a couple sub-requests, perhaps an HTTP HEAD request involved?
UPDATE: Figured out how to do the PHP thing, at least for phpdev4.2.3. In httpd.conf, add the following:
# run PHP interpreter through a directory request Alias /processPHP/ "C:/phpdev/contentTypes/process.php/" <Directory "C:/phpdev/contentTypes/"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from localhost 127.0.0.1 </Directory>
Then I create a new directory, C:/phpdev/contentTypes/, and I add the following files:
AddType application/xhtml+xml .xhtml AddType image/svg+xml .svg
<?php $fileInfo = apache_lookup_uri($_SERVER["PATH_INFO"]); header("Content-type: ".$fileInfo["content_type"]); include_once(substr($_SERVER["DOCUMENT_ROOT"],0,-1).$_SERVER["PATH_INFO"]); ?>