Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Serve Different File Extensions

    I've seen some sites (can't find an example at the moment) where for instance a .txt file is displayed as a html page.

    How do they do that? Is it something with Apache?

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yup, either set in the main Apache httpd.conf or more likley in .htaccess, eg:

    Code:
    AddType text/html .txt
    AddType application/x-httpd-php .magic .cool
    Makes .txt files act as HTML, and .magic and .cool files act as PHP.

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    It is basically just changing what encoding the server says a certain file is when it serves it up. You can do it with Apache and IIS. Though doing such a thing isn't necessarily a recommended idea since it would just add a layer of ambiguity to the site if someone else needed to work on it.
    OracleGuy

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy
    It is basically just changing what encoding the server says a certain file is when it serves it up. You can do it with Apache and IIS. Though doing such a thing isn't necessarily a recommended idea since it would just add a layer of ambiguity to the site if someone else needed to work on it.
    Didn't realise you could do it with IIS (but then again, ive never touched IIS).

    Alot of sites use it to hide the server technology they are using, for example make all .html pages parse as PHP or ASP, but I agree, it can add a bit of confusion if anyone else ever has to edit it.

  • #5
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by missing-score
    Didn't realise you could do it with IIS (but then again, ive never touched IIS).
    Well you can't use your .htaccess method on IIS to do it but it certainly can be re-configured through the MMC to do the exact same thing.
    OracleGuy

  • #6
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy
    Well you can't use your .htaccess method on IIS to do it but it certainly can be re-configured through the MMC to do the exact same thing.
    Ahh right, sorry, I guessed you could do something like it on IIS but I thought you meant it was exactly the same

  • #7
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah thanks, I thought it would be an Apache thing but couldn't find anything related to it from searching! Ooh, now I can have cool file extensions!

  • #8
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm, this works for the .JPG but not the .XHTML ? (I was just playing about with it ! )

    AddType application/xhtml+xml .xhtml .jpg


  •  

    Posting Permissions

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