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 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Hide .php extension using .htaccess file

    Hi,

    I am trying to hide the .php on all my pages using the .htaccess file. I have seen a number of tutorials online all using the following code, however it isn't working for me.

    When I go to the page without putting .php it goes to 'error 404 not found'

    PHP Code:
    RewriteEngine on
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_FILENAME}.php -f
    RewriteRule 
    ^(.*)$ $1.php 
    Please help.. thanks!
    Last edited by penny94; 11-19-2012 at 07:51 PM.

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    PHP Code:
    RewriteEngine on
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteCond 
    %{REQUEST_FILENAME} !-f
    RewriteRule 
    ^(.+)$ $1.php [L

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,338
    Thanks
    60
    Thanked 527 Times in 514 Posts
    Blog Entries
    4
    You could always change the file extensions to .html instead and then use this in your htaccess:

    AddType application/x-httpd-php .html

    That will make apache use php for .html extensions. You could also use any other extension such as .ico, .ttt, .any just to completely confuse any potential attacker but note that they may still get the server specs from a head request and if it only reveals php and no perl then it may still give the game away.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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