Page 1 of 1

How to hide .php extension

Posted: Tue Apr 27, 2010 9:03 pm
by jerrellbryant
Hello Everyone,

I am attempting to hide the .php extension on my website so that link to my pages will not look like this ( .../pages/test.php) but rather look like this ( .../pages/test/ ) .

I have been google searching for answers and received a bunch of articles but none of the methods discussed seem to work for me... I contacted my host provider which happens to be 1and1.com and was informed the server is running Apache, so I have attempted to use .htaccess file with the following code :

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/robots\.txt$ [NC]
RewriteCond %{HTTP_HOST} !^www\.[a-z-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z-]+\.[a-z]{2,6})$ [NC]
RewriteRule ^/(.*)$ http://%1/$1 [R=301,L]
ServerSignature Off

but it is not working properly.. can someone point me in the right direction... maybe I need additional files to make above work? Please help

Thank You

Re: How to hide .php extension

Posted: Wed Apr 28, 2010 6:06 pm
by Benjamin
:arrow: Moved to Installation and Configuration

Re: How to hide .php extension

Posted: Tue May 04, 2010 3:44 pm
by jerrellbryant
Can anyone help me with this issue? I have still not resolved. Thanks In Advance.

Re: How to hide .php extension

Posted: Wed May 12, 2010 9:55 pm
by dev008
Hello,

please use the givne below code it will solve you problem... :drunk:


Options +FollowSymLinks -MultiViews -Indexes

RewriteEngine On
RewriteBase /
RewriteCond %{ENV:REDIRECT_STATUS} !^401$
RewriteCond %{REQUEST_URI} !^/(payment|admin|provider|partner)/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ dispatcher.php [L]


thanks!
thephpexpert

Re: How to hide .php extension

Posted: Thu May 13, 2010 9:12 am
by jerrellbryant
Dev008 thank you for your help. So I would take the script you have provided and place it in my .htaccess file and place it on the root correct?