Still writing old school php? At least hide your .php extension
Hiding your php file extension via mod rewrite and .htaccess in Apache
posted on Apr 03rd
Since almost everyone is now programming in some complex web development framework (mine being Symfony), the days of programming old-school php (read with pages like contact_us.php and about_us.php) are basically dead.
Still, there is a time and a place for such simple applications. Just today I wrote one, but I still wanted the cleanliness of having urls WITHOUT the .php extension. The solution, as pieced together via forums is to place the following into your .htaccess file:
Result:
http://example.com/test --> http://example.com/test.php
(meaning that the user sees just "test" in the browser, but sees the result of executing the test.php script)
Even better, if the actual file exists, then apache routes straight to that file. This means that you can still go directly to http://example.com/test.php. It also means that routing to your images, stylesheets and javascript won't be disturbed.