# extensionless php file

**URL:** <https://forum.virtualmin.com/t/extensionless-php-file/46531>\
**Category:** Virtualmin\
**Created:** [August 19, 2013, 6:26am UTC](https://forum.virtualmin.com/t/extensionless-php-file/46531 "2013-08-19T06:26:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Terre\_Porter](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@Terre\_Porter](https://forum.virtualmin.com/u/Terre_Porter)\
**Post date:** [August 19, 2013, 6:26am UTC](https://forum.virtualmin.com/t/extensionless-php-file/46531/1 "2013-08-19T06:26:55Z")

</div>

I’m having trouble getting the ForceType to function when trying to use a extensionless file name.

I have a vm development box, os details at bottom of post (centos 6.4, httpd 2.2.15, php 5.5.3)

I have the following in my VirtualServer’s public\_html

`
#ls -al no-extension-test
-rw-r--r-- 1 phptesting phptesting 27 Aug 19 01:55 no-extension-test
`

Its contents are :

`
<?php
echo “a simple test”;
?>
`

Then in my .htaccess I have :

`
RewriteEngine On
<Files “no-extension-test”>
#1
#ForceType application/x-httpd-php
#2
#ForceType fcgid-script
#3
#SetHandler fcgid-script
#4
#ForceType application/x-httpd-php

`

When I use #1 or #4, I get a blank page but if I view source then I get the source code for the no-extension-test file

When I use #2 or #3, I get a Internal Server Error with the following in the logs

[Mon Aug 19 02:07:23 2013] [warn] [client x.x.x.x] (104)Connection reset by peer: mod\_fcgid: error reading data from FastCGI server  
[Mon Aug 19 02:07:23 2013] [error] [client x.x.x.x] Premature end of script headers: no-extension-test

I have another page, phpinfo.php (it works find)

Anyone have any suggestions ?

Any pointers on what to try next?

#-- Info

# cat /etc/redhat-release
`
CentOS release 6.4 (Final)
`
# uname -a
`
Linux devbox.nunya.lan 2.6.32-358.14.1.el6.x86_64 #1 SMP Tue Jul 16 23:51:20 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
`
# php -v
`
PHP 5.3.3 (cli) (built: Jul 12 2013 20:35:47)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
`
# httpd -V
`
Server version: Apache/2.2.15 (Unix)
Server built: May 17 2013 13:42:07
Server's Module Magic Number: 20051115:25
Server loaded: APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture: 64-bit
Server MPM: Prefork
  threaded: no
    forked: yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
`

---

<div class="post-metadata">

**Author:** ![Locutus](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/l/90ced4/32.png) [@Locutus](https://forum.virtualmin.com/u/Locutus)\
**Post date:** [August 19, 2013, 11:45am UTC](https://forum.virtualmin.com/t/extensionless-php-file/46531/2 "2013-08-19T11:45:34Z")

</div>

I don’t think the directives you tried can work this way…

According to the Apache documentation, “ForceType” is for static content only:

_“This directive primarily overrides the content types generated for static files served out of the filesystem. For resources other than static files, where the generator of the response typically specifies a Content-Type, this directive has no effect.”_

And the SetHandler you can’t have files be processed as an “fcgid-script”, that only applies to “.fcgi” files. When you use the FCGID method, the “FCGIWrapper” directives in your virtual hosts are responsible for telling Apache what files to run as FCGI:

`AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/DOMAIN.TLD/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/DOMAIN.TLD/fcgi-bin/php5.fcgi .php5`

You could try adding an “FCGIWrapper” directive and leave the “.php” extension out.

Question is though: _why_ would you need to call extensionless files as PHP scripts?

---

<div class="post-metadata">

**Author:** ![Terre\_Porter](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@Terre\_Porter](https://forum.virtualmin.com/u/Terre_Porter)\
**Post date:** [August 19, 2013, 4:05pm UTC](https://forum.virtualmin.com/t/extensionless-php-file/46531/3 "2013-08-19T16:05:28Z")

</div>

Thanks for the reply, I’ll try to explain where this comes from.

The use of ForceType is rather old, I’d say maybe 10 years… since I’ve been using this on a live site for about that long. There might have been something else but I can’t remember and I don’t have revisions on the .htaccess going back that far.

Basically, it was a way to make friendly urls. It working on httpd version 2.2.3 however the new server is running 2.2.15 and it doesn’t work now.

I just check the live hosting server and it’s httpd version is 2.2.24 which tosses out the version difference as a culpruit.

Here is what my live .htaccess code.  
`
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.$ - [NC,L]
RewriteRule ^.$ index.php [NC,L]`

 ForceType application/x-httpd-php In the root directory there would be a file with out an extension, named "content\_images".

It would contain either full php code or just a simple include statement.

`<?php include('content_images.php'); ?>`

This would allow for friendly url’s to be written like, [www.example.com](http://www.example.com)\content\_images\section1\year\month\day\articlefile1.jpg

The php would parse this url and and either generate the image or load the cached image.

Its not the only use but a good example of why it was used.

Weird that its not working though…

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [April 30, 2020, 5:58am UTC](https://forum.virtualmin.com/t/extensionless-php-file/46531/4 "2020-04-30T05:58:39Z")

</div>

Closed on April 30, 2020, 5:58am UTC


