Friday, June 23, 2017

How to ignore .php extention in url for Wamp and UWamp

Follow are the step to ignore .php extension in URL 1 :

  1. First, you need to enable the "rewrite_module" in your apache.
  2. Second, create a ".htaccess" file  inthe root folder of your web folder with the following contents :
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,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]