Tutorial: Treat HTML files as PHP ones

Started on the old forum in February 2011 · view the original in the archive · old links redirect here

1 reply · 1,363 views · started 15 years ago · 1 min read

2 participants
Mysterio Lead · 630 posts #1

This tutorial is for medium level users.

Yesterday, I downloaded a free flash template from internet, and I directly faced a problem. The template had this structure:

index.html text.html flashfile.swf images/

As you may understand, all the content used for menu and for pages was stored into the text.html as a normal text document, but I wanted that the content into the website to be dynamic (updating pages from database). But, changing from text.html to text.php will not do the job as the flash file will request for text.html and will not find it.

So, I thought for a way of "manipulating" the text.html to be treated as text.php but still remains text.html in the flashfile.swf's eyes. Adding this short code into .htaccess parallel with other files will do the job:

AddHandler x-httpd-php .html .htm .php

But now the new servers will need this code:

AddHandler application/x-httpd-php .html .htm .php

or

AddType application/x-httpd-php .html .htm .php

The above case it's just one of many others you may need to do this. Another case may be if you have a big site in html, and you want to convert it into a database driven one, but renaming files from .html to .php will just cause loose of visitors, because they have stored your pages as bookmarks as .html.

Hope it was helpful for you and you will know to manage it in your own interes.

mysterio.al - programming is a functional art

Ponick Developer · 216 posts #2

not only html ,people can use their own extension too like exe,asp!! 2 years ago i used this tricks to use jsp script as php.Now my server updated ,they added suphp and disabled .htaccess .but php.ini still support. php.ini sucks i can't edit it .do you know any way to use this tricks with php.ini?

P.s:remember if ur server not support this features in htaccess people will not see ur page as script, they will see it as a downloadable file!!most of time urscriptname.data file!! I lost my many source code lol

/* I don't know everything hehe */

Find me on facebook

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close