Results 1 to 12 of 12
  1. #1
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    PHP on .HTML - .SHTML Pages
    Hello,
    I have an older site that I am reworking...
    I am reworking it with PHP - the problem is that I DO NOT want to lose pagerank on the current pages.. so I do not want to change the extension but I want to use PHP...

    This CAN be done with .htaccess with HTML Pages...

    .HTACCESS for PHP to work on HTML pages

    ForceType application/x-httpd-php
    AddType text/x-httpd-php .html


    The ABOVE will make PHP work on pages ending in HTML

    BUT My pages end in SHTML
    and this doesn't work for SHTML pages even if you change the HTML to SHTML..
    There is something missing....???

    Anyone know what it is..??

    ANY HELP WOULD BE APPRECIATED......

  2. #2
    ABW Ambassador DesignerWiz's Avatar
    Join Date
    January 18th, 2005
    Location
    U.S.A
    Posts
    2,777
    Did you try adding this to .htaccess ?

    AddHandler application/x-httpd-php .htm .html
    ForceType application/x-httpd-php .html .htm
    Ray Thomas
    Webmaster Resources: http://DesignerWiz.com
    ABW Board Category: Programming / Coding
    http://forum.abestweb.com/forumdisplay.php?f=190

  3. #3
    ABW Ambassador DesignerWiz's Avatar
    Join Date
    January 18th, 2005
    Location
    U.S.A
    Posts
    2,777
    Here's another example to try.

    AddType text/html .shtml
    AddHandler server-parsed .htm
    AddHandler server-parsed .html
    AddHandler server-parsed .shtm
    AddHandler server-parsed .shtml
    ForceType application/x-httpd-php .html .htm
    Ray Thomas
    Webmaster Resources: http://DesignerWiz.com
    ABW Board Category: Programming / Coding
    http://forum.abestweb.com/forumdisplay.php?f=190

  4. #4
    Action Jackson - King of the World
    Join Date
    January 18th, 2005
    Posts
    2,201
    does this mean all your php pages would be seen as html pages? Could I do something similar with the Amazon feed?

  5. #5
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    You can have Apache treat any file or file extension as a PHP file. I remember doing one that matched some of thise Windows/IIS files that the worms go looking for (default.ida) in order to log and mess with them. You can even map what looks like a directory to a PHP script.
    Tim
    consultant by day, affiliate by night

  6. #6
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    DesignerWiz - niether one of those examples worked for me...
    the PHP still will not show.. I get 500 errors..

    jackson992 - if you want to paste some PHP onto an HTML page and test it..
    just paste this into your htaccess file - and then open the HTML

    ForceType application/x-httpd-php
    AddType text/x-httpd-php .html



    I just can't get it to work with SHTML pages..??
    I am working on an older site and the pages have good pagerank so I don't want to change the extension of the pages..?

  7. #7
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    Should that be

    AddType application/x-httpd-php .html

    instead of

    AddType text/x-httpd-php .html


    I have something like:

    AddType application/x-httpd-php .php .html .xml .shtml
    Tim
    consultant by day, affiliate by night

  8. #8
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    SUCCESS AT LAST

    I finally got it to run PHP on a page with a .SHTML Extension!


    One Line In The .HTACCESS

    AddHandler application/x-httpd-php .shtml

    and you could add others

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


    Thanks Guys
    Your help is appreciated...
    I just put together some of that stuff until I got it to work!
    I really don't mess with HTACCESS that much.

  9. #9
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    Looking at it again - DESIGNERWIZ was right the first time...
    But for some reason it didn't work the first couple of times I tried it with what you posted??? wierd maybe there was something else in the cut and paste that shouldn't have been there..

    I did change the .htm .html
    to just plain .shtml
    but I don't think that would have messed with it ya think..??

    Anyway it's working
    Thanks again


  10. #10
    Member infoscott's Avatar
    Join Date
    March 17th, 2005
    Posts
    126
    Hey SuZe,

    I'm guessing you had .shmtl pages because you were using Server Side Includes. Did the server parse both the PHP and the includes correctly? This is my Holy Grail right now!

  11. #11
    ABW Ambassador AddHandler's Avatar
    Join Date
    January 19th, 2005
    Posts
    1,270
    infoscott - No it will not parse both the SHTML and PHP - it is one or the other.
    Unless someone else knows how to get it to do BOTH...??


    BUT - if you want a PHP include -- "Almost like a SSI" BUT BETTER...
    Here is one I use..


    HTML Code:
    <?php
    $txt_array = Array();
    $my_dir = "/home/domain/folder/"; //Replace it with your random link directory (dont delete the END slash)
    if ($dir = @opendir("$my_dir")) {
     
    while (($file = readdir($dir)) !== false) { 
    if ($file != "." && $file != ".." && !is_dir($my_dir.$file)) 
    {
    /* echo $my_dir.$file."<br>"; DEBUG show file list */
    $txt_array[] = $file;
     
    } 
    } 
    closedir($dir);
    }
     
    $random_number=rand(0, count($txt_array)-1); 
    $random_txt=$txt_array[$random_number];
    include($my_dir.$random_txt);
    ?>
    It is a "RANDOM" Include which is nice..
    The include points to a folder and whatever documents you have in that folder is what it rotates.. if you do not want it to rotate just put one file in the folder.... it accepts -- HTM HTML TXT extensions in the rotating folder..


    Hope That Helps


    __________________________________
    Where are the signatures..??
    Did They Go -

  12. #12
    Member
    Join Date
    January 18th, 2005
    Posts
    145
    One thing that you may be able to do is include the php script inside of an shtml page via the SSI include file=content.php directive.

    I use this to include the content from a PHP script into my index page.

  13. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Using PHP (or JS) on .htm or .html pages
    By webworker in forum PopShops
    Replies: 42
    Last Post: September 18th, 2011, 12:09 PM
  2. .PHP pages versus .HTML pages?
    By sixeden in forum Search Engine Optimization
    Replies: 7
    Last Post: January 20th, 2007, 05:24 PM
  3. Carp php in .shtml pages
    By kapsat in forum Programming / Datafeeds / Tools
    Replies: 9
    Last Post: January 2nd, 2005, 06:23 PM
  4. Making .html pages be parsed as .php
    By ~Michelle in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: June 6th, 2004, 09:20 PM
  5. changing files from .html to .shtml
    By perfectG in forum Search Engine Optimization
    Replies: 8
    Last Post: March 18th, 2003, 03:16 AM

Posting Permissions

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