Forced header/footer with htaccess

Discussion in 'Apache' started by Cashable, Jul 2, 2008.

  1. #1
    I have a file hosting site that is set up so that a link is sent out to a new file, but when you click on the link, all you see is the file (usually an image, but could be any type of file). I would like to force a header and footer on there, so it is better looking, and I can have some ads on there, as well as a link to the front page. I have it working, but since most of my files are images, they just show up as garbled text.

    Here are the two important files:

    htaccess

    
    AddHandler headered .gif
    AddHandler headered .jpg
    AddHandler headered .png
    AddHandler headered .zip
    AddHandler headered .tar
    AddHandler headered .gz
    AddHandler headered .jar
    AddHandler headered .mpe
    AddHandler headered .pdf
    
    Action headered /uploads/autowrap.php
    Code (markup):
    And the autowrap.php file that is called:

    
    <?php
    
    $header = "sidebar.php";
    $ads = "ads.php";
    $footer = "footer.php";
    
    $file = $_SERVER["PATH_TRANSLATED"];
    readfile($header);
    readfile($ads);
    readfile($file);
    readfile($footer);
    
    ?>
    Code (markup):
    Sorry, I can't give an example as I had to deactivate this, due to it not working. Here is what is looks like when I try to view an image:

    
    ����JFIFdd��DuckyK��Adobed������!�� !1AQaq�
    Code (markup):
    It goes on for pages like that.

    Any ideas how I can get this to work? The header, ads and footer all show up correctly, just the image/file that is supposed to be there is not.

    Thanks in advance!
     
    Cashable, Jul 2, 2008 IP
  2. hostrs.com

    hostrs.com Peon

    Messages:
    157
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    hum.. weired problems. If you have a file hosting website. For user downloads why add a little coding to make php add the extension on file download?
     
    hostrs.com, Jul 12, 2008 IP