Posted By

nshakin on 11/02/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

o0110o


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 /
  5.  
  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]
  9.  
  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  

Comments

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

thanks.very good

You need to login to post a comment.