DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Replace File Extension With Apache Rewrite

  • submit to reddit
        // in this example *.html is replaced by *.php
// its a redirect [R] and it is is permanent (code is 301)

RewriteEngine On
RewriteBase   /the_directory

RewriteRule  ^(.*).html$ $1.php [R=301]


Snippets Manager replied on Thu, 2006/05/18 - 10:47pm

Or, without the RewriteEngine: RedirectMatch perm ^/the_directory/(.+)\.html$ http://host.example/$1.php