#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0

    Force html as php pages in htaccess


    If somebody please can explain,
    I have in my htacces telling apache to treat all html pages as php,
    I just read in a hosts instructions to avoid doing that as it takes a lot of cpu resources, and my problem is cpu resources...

    They say this;
    AddHandler application/x-httpd-php5 .html .htm
    It is highly recommended that you never allow html pages to automatically handle php or shtml, because this forces all of your html pages to be processed by the server first. Instead, please rename your files to .php or .shtml whenever possible.

    I wonder if this is true, as I can do a redirect not to loose my backlinks but I dont want to change index.htm to index.php as it been that way for then years.
    So what can I do?
    1st, I could call all new pages .php instead of .htm,
    however dont know if site looks funny having some pages with name .htm and other with .php?
    2nd. I could rename all pages to .php that are not important and dont have backlinks, that way apache dont have to force html to php on all pages.

    Please advice

    However I dont use addhandler but suppose its the same, forcing apache:
    AddType application/x-httpd-php5 .htm .html
    Last edited by helenp; January 28th, 2012 at 08:40 AM.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If all of your html files contain PHP then renaming them to .php won't change anything.

    You would only be able to realize a performance improvement if some of your files contained pure-HTML and others contained PHP/HTML. In that case, you should distinguish between them by naming your pure HTML files with a .html or .htm extension, and naming your PHP/HTML files with a .php extension; then disable processing of HTML files as PHP. The server will then be able to serve the pure-HTML files as pure-HTML, which is significantly faster than serving them as PHP. Your PHP/HTML files will still be served as PHP, so there will be no performance difference there.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,127
    Rep Power
    4304
    How many of your .htm and .html files don't have any PHP code in them?

    They just don't want you to waste server resources by making the PHP parser be used when it's not really needed.

    However I dont use addhandler but suppose its the same
    Yes, it has the same affect.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Marbella, Spain
    Posts
    381
    Rep Power
    0
    Ok thanks,
    No I think all pages have php as I have a searcherbox in all pages, so there is nothing I can do there then.

IMN logo majestic logo threadwatch logo seochat tools logo