View Full Version : Dynamic .htm pages from .php page code
Abhimanyu
02-10-2007, 09:21 AM
Hello everyone,
I am new to this site.I hope i will get correct help from here.
I want to generate .htm pages from dynamic .php code.
Let me explain it >>> suppose i have a link called 'search', and on clicking that link the site is directed to search.php. But instead of search.php it should display search.htm in url though the code is running from search.php page.
Is it possible? or just not?
greenowl
02-11-2007, 04:48 AM
You can do that with a htaccess file. ;)
djr33
02-11-2007, 05:18 AM
extensions don't "mean" anything... nor do they change how a file works.
They act as notes to the system and sometimes the user.
If you see a .jpg you know it's an image. Likewise, any file named .jpg, the browser will know to show as an image. You'll get some weird errors if you rename a .htm to .jpg, etc.
However, as long as the browser knew it to be an html file, that would work just fine having it simply named .jpg (though this wouldn't be the case as this is how browsers are designed).
So... to get to the point...
Your server is configured to read .php as an entension which should be parsed by the PHP interpreter. All you need to do is set it to parse .htm and .html, etc. as well.
You can do this through the .htaccess config file on your server. However, I don't know the exact code. It has been posted several times, so just search for ".htm php .htaccess" and you should come up with something.
BLiZZaRD
02-11-2007, 03:44 PM
make a new .htaccess file:
open notepad or other plain text editor and save as .htaccess (notice the "dot" at the beginning) be warned that it will sometimes save as .htaccess.txt if this is the case just use the "rename" ability and remove the .txt.
Newxt, add this to it:
AddType application/x-httpd-php .html .htm
AddHandler application/x-httpd-php .html .php .htm
Now you can have php code inside an htm, or html file and it will get parsed correctly as such :D
save it, and upload to the root level of your server. done.
djr33
02-12-2007, 12:11 AM
Another fun option would be allowing .jpg and such so you can have dynamically generated images ;)
One note about the above post though. DON'T do that :p
Copy the .htaccess file off your server, edit in notepad, adding those two lines, THEN upload and replace the file.
Otherwise, you'd loose all of your current .htaccess info.
mburt
02-12-2007, 01:10 AM
extensions don't "mean" anything... nor do they change how a file works.
I disagree actually. Try this: save an image as a .bmp then manually change the extension to .png, or whatever. It will still be in .bmp format (size, quality, etc.) The same way for .htm and .php. If you have php tags in a .htm/.html document the browser will try to write them as text or escape characters.
djr33
02-12-2007, 05:54 AM
The bytes are identical. The file extension is just a pointer to tell the computer what to do with it. If you rename it .png and the computer can handle it, great. But some programs would be confused, especially apps that only support bmp as they would not open it or apps that only support png and get confused at the way the file is organized.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.