Posted By

nshakin on 11/02/12


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Hide .php Extension From Browser Address Bar

 / Published in: Apache

Add source to .htaccess file and server will hide .php extensions. href tags must reference the file name without the extension .php in order to work properly.

  1. Options +FollowSymLinks -MultiViews
  2. # Turn mod_rewrite on
  3. RewriteEngine On
  4. RewriteBase /
  6. # To externally redirect /dir/foo.php to /dir/foo/
  7. RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
  8. RewriteRule ^ %1 [R,L]
  10. # To internally redirect /dir/foo/ to /dir/foo.php
  11. RewriteCond %{DOCUMENT_ROOT}/$1.php -f
  12. RewriteRule ^(.*?)/?$ $1.php [L]

Report this snippet  


RSS Icon Subscribe to comments
Posted By: tux-world on June 18, 2013

thanks.very good

You need to login to post a comment.