Hiding php

Discussion in 'PHP' started by look4guna, Sep 17, 2010.

  1. #1
    Hi,
    I've seen in a webpage that we can hide the .php extension by over riding some settings in httpd.conf file like, DefaultType text/plain => DefaultType application/x-httpd-php

    see this url: http://php.net/manual/en/security.hiding.php

    so the server parses a web page which comes without an extension as a php page.

    The problem here is it doesn't works for me, what i did is i've changed the settings as above and created a file like test and within that i echoed some text. when i run the test page, the browsers shows like a text file.

    the test page content is,
    <?php
    echo "hio";
    ?>

    can anyone tell me how to set these settings right?
     
    look4guna, Sep 17, 2010 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    on your php ini file, put expose_php to off

    there are many ways to hide extensions, best way would be by doing it in .htaccess
     
    bartolay13, Sep 17, 2010 IP
  3. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #3
    example in htaccess

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

    for instance you can make your extension names .myfiles

    AddType application/x-httpd-php .myfiles
     
    lowridertj, Sep 17, 2010 IP
  4. look4guna

    look4guna Active Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    Hi,
    thanks for your replies, but am new to php,so i know only little about htaccess that we have a .htaccess and we've have to set all our configurations within that file. I tried it after your reply, like create a .htaccess file within that file i set rewrite engine on and tried for hidden redirect for testing purpose but actually when i run the page it shows some error. it seems like .htaccess file is not properly configured. can u tell me how to setup the .htaccess file and configure to hide extensions.

    am working in red hat linux platform, Thank you..
     
    look4guna, Sep 17, 2010 IP
  5. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #5
    are you looking for a redirect or to hide the extension of the file and still process php?

    thats 2 separate things?
     
    lowridertj, Sep 17, 2010 IP
  6. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #6
    If you want to hide the .php part of a file called test.php you can do this, which doesn't require mod_rewrite.

    PUT this into a .htaccess file
    
    <FilesMatch "^test$"> 
      <  ForceType application/x-httpd-php >
    </FilesMatch> 
    
    PHP:
    The file on your server will still be called test.php but you can call the file like this
    siteUrl.com/test
    Code (markup):
     
    MyVodaFone, Sep 17, 2010 IP
  7. look4guna

    look4guna Active Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    Hi friends,
    thanks for all your suggestions ,actually my question is hiding .php extension without using .htaccess. Is it possible?
     
    look4guna, Sep 18, 2010 IP