Jump to content

Recommended Posts

Posted

tldr;

I'd like to add an `.htaccess` rule to rewrite `*.phps` URLs to their actual `.php` source document, but instruct FastCGI to syntax highlight and render the source file as HTML instead of interpreting it.

Some due diligence:

  • I searched the forums for:
    • "phps" (Old thread from 2009 about bypassing apache/suPHP configs and highlighting via `RewriteRule /highlight.php?file=$1`.)
    • "fastcgi" (Nothing obviously php/fastcgi/htaccess related.)
    • "fcgi" (Nothing obviously php/fastcgi/htaccess related.)
    • "handler" (There's an old thread about telling apache to process `.pro` files as PHP.)
    • "htaccess" (Nothing obviously php/fastcgi/htaccess related.)
    • etc.
  • I searched the wiki.
  • I've done loads of Google searches similar to the above, and read dozens of StackOverflow QAs.
  • I've browsed the Plesk docs, but they don't get to the level of config file detail.
    • I've tried adding a `SetHandler fcgid-script` (among many others) in my `.htaccess`.
  • I've experimented with a bunch of stuff in my Heliohost Marty space.

General info:

  • Morty username: beporter
  • Site: https://gravatar.redirect.channel 
  • PHP file URL: https://gravatar.redirect.channel/gravatarizer.php (On its own, configured to bounce invalid requests back to the homepage.) 
  • Desired .phps URL: https://gravatar.redirect.channel/gravatarizer.phps (should render html version of the source code for the `.php` version of the same filename.)
    • I tried symlinking this in git, but:
      1. the Plesk logs say I can't use `<Directory>` which means I can't use `Options FollowSymlinks` either.
      2. According to the Plesk file browser, git doesn't push the symlink over SFTP, at least not with the Github Action I've been using.
  • Example non-functional `.htaccess` rules:

 

# Allow PHP source code to render as text for inspection

AddType application/x-httpd-php-source .phps
# RewriteRule ^(.+\.php)s$ $1 [H=application/x-httpd-php-source]
# --or--
# RewriteRule ^(.+\.php)s$ $1 [H=php-script]

# Allow examining .phps files.
# <FilesMatch "\.phps$">
#   SetHandler application/x-httpd-php-source
# </FilesMatch>

If this were `mod_php` in Apache, I suspect that first commented-out RewriteRule would have been sufficient. But since PHP files are passed through to FasgCGI, it seems like that Apache handler isn't recognized or responding.

What I can't find is documentation on how Heliohost has named its PHP handlers. I found a support page about using the plesk cli tool, but obviously I can't run that myself.

It's totally fine if this is outside the realm of possibility, but since this whole single-page-site is meant to be a learning experience, it'd be nice to get this working in the`.htaccess`, if possible.

Thanks for your time!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...