0

Possible Duplicate:
Redirect *.htm to *.php
htaccess rewrite if redirected file exists

I set up a website a while ago and I had all the extensions as .html. I've learned a bit more about web development and would like to have everything as .php. The problem is that some of the pages have been bookmarked so I can't just change all the links and remove the .html files. I understand I could just add redirects on each page, but that would mean having two of each page on my site.

I'm wondering if there is a way using .htaccess to redirect any *.html to *.php if *.php exists.

Community
  • 1
  • 1
mowwwalker
  • 15,446
  • 25
  • 95
  • 152

1 Answers1

1
RedirectMatch 301 (.*)\.html$ $1.php

or In your apache httpd.conf file you can add

AddType application/x-httpd-php .html
Manigandan Arjunan
  • 2,250
  • 1
  • 24
  • 41
  • 1) `AddType` is inappropriate; `AddHandler` should be used. 2) processing all files with an extension of "html" as PHP scripts doesn't address Walkerneo's issue and is wasteful. – outis Mar 29 '12 at 00:51