Results 1 to 7 of 7

Thread: Dynamic .htm pages from .php page code

  1. #1
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Dynamic .htm pages from .php page code

    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?

  2. #2
    Join Date
    Feb 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You can do that with a htaccess file.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    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:

    Code:
    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

    save it, and upload to the root level of your server. done.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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
    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

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

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •