Reputation: 19
I have created the .htaccess file to rewrite url for .php
Before creating the .htaccess files
Url was like : www.xyz.com/contact.php
After creating the file
Its like : www.xyz.com/contact
But if someone writes in the url
www.xyz.com/contact.php
The .PHP extension is displayed hoe to hide it even if someone enters it manually
Upvotes: 0
Views: 160
Reputation: 4302
the following code will remove .php even if users write it :
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.php[\s?/] [NC]
RewriteRule ^ /%1%2 [R=302,L,NE]
Upvotes: 1