I have a web application, and it has a RESTful PHP backend that uses Zend framework (which does its own URL rewriting magic).

The problem is, my backend's entry-page is api.php and the endpoints look like:


All I want to do is remove the .php file extension so my URLs look a little cleaner.

Is there any way of doing this without removing the file extension from the PHP file?

2 Answers 2


Rewrite rule in .htaccess:

RewriteRule  ^test(/.*)?$ test.php?path=$1

Contents of test.php:

   echo ($_GET['path']);

Then when I hit /test/foo/bar on my server, the PHP page prints out /foo/bar.

  • Sorry dude, doesn't work for me. I'm pretty sure this is something to do with .htaccess rules conflicting with Zend Framework's own URL rewriting stuff. After adding your rule to my .htaccess file, it just gives me a 404 :( May 27, 2013 at 16:06

Try this to just remove .php:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.