Tuesday, January 11, 2011

Rewrite php file extensions to HTML

Most of the developers like to show PHP files as HTML. This can be done via htaccess. .htaccess files (or “distributed configuration files”) provide a way to make configuration changes on a per-directory basis. In htaccess, we have Rewrites. Htaccess Rewrites are enabled by using the Apache module mod_rewrite, which is one of the most powerful Apache modules and features availale. Htaccess Rewrites through mod_rewrite provide the special ability to Rewrite requests internally as well as Redirect request externally. So, if URL comes like http://www.vijayakumar.org/example.html. This URL will be rewritten as http://www.vijayakumar.org/example.php. To do this, we want to place the below line into htaccess, which was presented in root directory(htaccess will be hidden, try accessing hidden files in your root directory. If not presented?, please create a new htaccess file in root directory).

RewriteRule (.*)\.html $1.php

No comments:

Post a Comment