Jump to content

Parsing pages that DON'T end in .php


Recommended Posts

How/where is the setting that tells PHP which pages to parse? Does Apache have it and sends the file to the PHP engine? I have a custom extension that I am using and the server isnt parsing it because its not php extension.

Edited by Karaethon
Typo Correction
Link to comment
Share on other sites

I looked at everthing settings related and I cant find the setting for it. But I decided it's not hard to change the file to standard php extension so thats better, especially since I may not be able to edit settings on final server.

Link to comment
Share on other sites

The association with a handler and files of an extension or specific name is part of the apache configuration.  

There are actually a couple of different ways of doing it, and some potential security ramifications which are discussed in this blog post.  It is possible to make these settings in an .htaccess file if the server has been configured to allow it.

<FilesMatch \.foo$>
SetHandler application/x-httpd-php
</Files>

This block would need to be inside a directory block if it's in an apache config for a vhost, but would be fine in an .htaccess.  Note the basic regex which insures that myfile.foo will get parsed as php, but myfile.foo.jpg will not.  This was a common exploit used to attack apache servers with php applications which allow uploads of images for example.  

Link to comment
Share on other sites

4 hours ago, benanamen said:

The one thing that hasn't been mentioned is WHY would YOU want to do this in the first place?

Its kinda silly. I have code snippets, pieces of code that i use often in several places, so i save them as .snip, when I include them they run php code but i needed to call one via ajax and it wasnt running php code because it wasnt .php 

i finally realized that giving it a ohp extension was the logical, least effort, option.

Link to comment
Share on other sites

On 6/28/2019 at 8:25 PM, Karaethon said:

Its kinda silly. I have code snippets, pieces of code that i use often in several places, so i save them as .snip, when I include them they run php code but i needed to call one via ajax and it wasnt running php code because it wasnt .php

Don't do that. Make a page specifically for the AJAX request that "calls" the snippet.

And just stick with .php. It's more portable, both for running and for editing. If you want your snippets (I term I hate, by the way) to be separate then put them in a dedicated directory or something.

Link to comment
Share on other sites

On 7/2/2019 at 8:58 AM, requinix said:

Don't do that. Make a page specifically for the AJAX request that "calls" the snippet.

And just stick with .php. It's more portable, both for running and for editing. If you want your snippets (I term I hate, by the way) to be separate then put them in a dedicated directory or something.

Yeah, thats what I ended up doing. and why hate 'snippets'? thats what they are, pieces of html that by themselves are just a piece of the whole page. like footer, header, menu, etc. what would you call them? pieces? chunks? (truffle shufle)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.