SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict grimsqueaker's Avatar
    Join Date
    Jan 2006
    Location
    Nova Scotia, Canada
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php include without changing file extension?

    Just wondering if there was a way to have a php include without changing the file extension of a webpaage from .html to .php? The site I'm working on has already been established for a very long time, and changing the extension of files will cause utter chaos with backlinks/sitelinks/etc.

    I want to implement php includes for the header/footer/etc. so they don't have to update every single webpage when they want to make change. If this is not possible with a php include, is there a way to acheive the same effect using different method?

    Thanks!
    Photoshop Tutorials, Freebies, News, and more!
    www.mintyferret.com

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Technically you can tell apache to treat .html files as PHP, but I don't recommend it. You probably want to use mod_rewrite. One way is to configure mod_rewrite to send all requests to one PHP file (e.g. index.php) with the path requested as a GET parameter. Then include the header, main content (based on the GET parameter), and footer files.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    If you are including files with "include or require" they can be any file extension and they will be parsed as php files.

    Now what I would do is use mod_rewrite to change all the URLs to extension-less and redirect all the old URL to the new ones. (Using redirect 301)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Addict grimsqueaker's Avatar
    Join Date
    Jan 2006
    Location
    Nova Scotia, Canada
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your suggestions guys!

    I decided to just go with a sideserver include instead, and chgne the htaccess files to disply .shtml as .html files, it seemed the easiest way.
    Photoshop Tutorials, Freebies, News, and more!
    www.mintyferret.com


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
  •