remove file extension htaccess not working

the following code is not working to remove the file extension .php

Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+)$ $1.php [L,QSA]

my url not changing from example/about.php to example.com/about


I have found the answer. Its working. the code is as follows to rewrite and redirect the url

Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## hide .php extension # 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 RewriteRule ^ %{REQUEST_FILENAME}.php [L]

It rewrites and redirects the URL. Thanks all for ur answers.


This RewriteRule should remove the .php extension from a request. Try placing it before your RewriteConds.

RewriteRule ^(.+)\.php$ /$1 [R]


try this

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php


try this

RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule ^(.*)$ $1\.php


RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*[^/])/?$ $1.php [L]


  • Redirecting error using .htaccess
  • Invalid controller specified() - Zend Framework
  • How to remove public/index.php from url in laravel 5?
  • htaccess mod_rewrite URL within subfolder
  • url rewrite not working .htaccess
  • Mod_rewrite handling extra get variables (QSA not working)
  • Accessing environment variables set using mod_rewrite in PHP
  • Can I used mod_rewrite to change file extensions? .jpeg to .jpg for example
  • htaccess will not rewrite subdomains
  • How ignore any files using HHVM proxygen rewrite rules?
  • Removing the .php file extension from the URL Request
  • Nginx rewrite equivalent to Apache RewriteRule that converts URL params into QueryString key/value p
  • Refactoring advice: maps to POJOs
  • Regex for URL rewrite with optional query string parameters
  • Ionic storage “get” returns null only on the second call within method
  • Primefaces lazy datascroller calling load twice
  • How to access meteor package name inside package?
  • Rest Services conventions
  • pip in virtualenv gets ConnectTimeoutError
  • SonarQube: Cannot deactivate rule with missing quality profile
  • Element.tagName for python not working
  • Apache RewriteRule redirection with url encoded
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • htaccess add www if not subdomain, if subdomain remove www
  • JSON response opens as a file, but I can't access it with JavaScript
  • Use of this Javascript
  • Cannot resolve symbol 'MyApi'
  • Accessing IRQ description array within a module and displaying action names
  • Adding custom controls to a full screen movie
  • Jquery - Jquery Wysiwyg return html as a string
  • Circular dependency while pushing http interceptor
  • Arrays break string types in Julia
  • AngularJs get employee from factory
  • WPF Applying a trigger on binding failure
  • How to set the response of a form post action to a iframe source?
  • -fvisibility=hidden not passed by compiler for Debug builds
  • Java static initializers and reflection
  • Change div Background jquery
  • need help with bizarre java.net.HttpURLConnection behavior
  • How can I remove ASP.NET Designer.cs files?