[colug-432] Setting up apache2 test server to show php formatted source (ubuntu 10.10)

Scott Webster Wood treii28 at yahoo.com
Fri Apr 22 11:30:41 EDT 2011


I haven't toyed with apache2 configs in a while things seem to be laid out a little different than I remember.  I have a reasonably vanilla ubuntu 10.10 install with apache2+php5 and I wanted to try to get mod_rewrite to allow typing a url for a php file as '.phps' to use the built-in source formatter on my test system.
I found a reference on how to attempt doing this in a couple of different places.  I found a couple of different versions of it (and have tried each - I'm showing commented as I currently disabled them until I find a working solution)

#  RewriteEngine On
#  RewriteRule (.+\.php)s$ $1 [H=application/x-httpd-php-source]
#  RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source]

the H= tells apache2 to use the handler for that mimetype (the source formatter) while the T= tells it to handle the file as that mimetype (the handler is specified in the default php5 config).

I've tried various versions of tweaking this directive, various context such as a <Location /> block in the default server file under /etc/apache2/sites-enabled/ and also in the <Directory /var/www/> block.

If I use the T= version it displays the same thing that I would get calling to the file.php (the processed code output as html).  If I use the H= version I get something akin to:

[Thu Apr 21 12:34:02 2011] [error] [client 127.0.1.1] script 'redirect:/query.php' not found or unable to stat

I know this is probably a rusty-admin PEBCAK type error, but does anyone know what I'm missing here to get this to work.  (there is no phps file - if you copy a php file to phps and pull it up in the web browser, it displays the formatted source.  I have literally hundreds of php files in this customer's website and I don't feel like cloning all of these files)

SW
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: SpamAssassinReport.txt
Url: http://lists.colug.net/pipermail/colug-432/attachments/20110422/41fa9931/attachment.txt 


More information about the colug-432 mailing list