Return to Snippet

Revision: 60325
at November 2, 2012 10:25 by nshakin


Initial Code
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# To externally redirect /dir/foo.php to /dir/foo/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To internally redirect /dir/foo/ to /dir/foo.php
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

Initial URL

                                

Initial Description
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.

Initial Title
Hide .php Extension From Browser Address Bar

Initial Tags

                                

Initial Language
Apache