Forum Moderators: phranque

Message Too Old, No Replies

AddType application for just one file in directory?

         

Jesse_Smith

9:24 am on Nov 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possible to make just one file in a directory be a certian kind of file? Like in the cgi-bin directory make one .cgi file be a php file?

AddType application/x-httpd-php file_name.cgi

doesn't do it.

jdMorgan

1:47 pm on Nov 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try enclosing it in a <FilesMatch> container, or rename the file itself and then use mod_rewrite to make it accessible by its original name:

FilesMatch:


<FilesMatch "^file_name\.cgi$">
AddType application/x-httpd-php .cgi
</FilesMatch>

-or-
Rename the file from file_name.cgi to file_name.php and then use:

AddType application/x-httpd-php .php
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^file_name\.cgi$ file_name.php [L]

The MIME-type would then be assigned according to the file's filetype, while the old file_name.cgi URL would still work.

Jim