Saturday, January 21, 2012

Simple rewriting using .htaccess


All requests to whatever.htm will be sent to whatever.php:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]

The [NC] part at the end means "No Case", or "Case-Insensitive".
Requests to the .html automatically rewrite to .php. 
Ex: If it is whatever.htm or whatever.php, but they always get whatever.php in the browser, and this works even if whatever.htm doesn't exist!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.