Can't use php includes on .html pages? Say it ain't so! Best work around?

5 replies
  • WEB DESIGN
  • |
I have a site that has 35 pages with more coming up. Always thought I would just switch over to php includes when the pages got to be too many to change the navigation easily. Thought the time had come and started looking around to find out how to do that and then find out that I need a .php extension instead of .html on all the pages.

Nearly all of these pages have back links and I really hate to clog up the files with that many redirects. Has anyone else gone through this and can suggest another way to make the change over?

And another related dumbie question, maybe I should start all sites with .php file extensions, even if I'm not using any php to begin with? I don't suppose it hurts anything to just use html for a .php page?

The things that can go wrong (!)

../lloyd
#html #includes #pages #php #work
  • Profile picture of the author aaron_nimocks
    Try putting this in .htaccess

    PHP Code:
    AddType application/x-httpd-php .html .htm 
    Signature

    My free PSD logs can be downloaded at PSD Bum. Enjoy!

    {{ DiscussionBoard.errors[1516311].message }}
  • Profile picture of the author ocmnet
    Add this to your .htaccess file in your home directory

    # The following will make php files will work with a htm(l) extension
    AddType application/x-httpd-php .html .htm


    If you don't have a .htaccess file, create one and include the following:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /

    # The following will make php files will work with a htm(l) extension
    AddType application/x-httpd-php .html .htm

    <Files php.ini>
    order allow,deny
    deny from all
    </Files>
    {{ DiscussionBoard.errors[1516324].message }}
  • Profile picture of the author JackTheLad
    Hey Lloyd,
    had a bit of a poke around the old interweb for you and found this -
    How to Redirect index.html to index.php | CSS-Tricks

    Not sure if it's exactly what you're looking for, but it might help you get there.

    Take it easy!
    {{ DiscussionBoard.errors[1516328].message }}
  • Profile picture of the author victorroestad
    Hi Loyd.

    I found something that might help you:

    This technique will only work if your Apache server has PHP enabled and .htaccess enabled. Do a search in google for "how to test php support in apache http server" to find out how to test this.

    In the root directory of your html files create a file named .htaccess. The file may already be present.

    Open the file in your favorite editor and add the following lines:

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

    Done!


    Warmest regards,

    Victor A. Roestad
    {{ DiscussionBoard.errors[1516338].message }}
  • Profile picture of the author Lloyd Buchinski
    Thanks everyone. A lot of this sounds really good.

    I can see that I have to start way back with a php template and redo the site a bit and it is going to be Tuesday before I can even start working on it. (Day job for the next 3 days.) Turns out I had just assumed I could add a bit of php to an html site but from a bit of reading today that doesn't seem true anymore.

    Does anyone happen to know if I loose page rank with these redirects? If so I might just tough it out and leave it up as html, maybe start another site for new material.
    Signature

    Do something spectacular; be fulfilled. Then you can be your own hero. Prem Rawat

    The KimW WSO

    {{ DiscussionBoard.errors[1516845].message }}

Trending Topics