Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-19-2012, 07:44 PM   PM User | #1
penny94
New Coder

 
Join Date: Sep 2012
Posts: 21
Thanks: 3
Thanked 0 Times in 0 Posts
penny94 is an unknown quantity at this point
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..
penny94 is offline   Reply With Quote
Old 11-19-2012, 08:55 PM   PM User | #2
poyzn
Regular Coder

 
poyzn's Avatar
 
Join Date: Nov 2010
Posts: 265
Thanks: 2
Thanked 61 Times in 61 Posts
poyzn is on a distinguished road
PHP Code:
RewriteEngine on
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteRule 
^(.+)$ $1.php [L
__________________
Ushousebuilders.com
poyzn is offline   Reply With Quote
Old 11-19-2012, 10:04 PM   PM User | #3
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,665
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
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.
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:34 AM.


Advertisement
Log in to turn off these ads.