Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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 :( – Hassan Khan May 27 '13 at 16:06

Try this to just remove .php:

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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