I'm migrating a site to a new server - the site is old and has a lot of .cfm and .asp files which are no longer useful but do still show up in search engines. The new server is Linux, and I don't want to install the site on a Windows server nor purchase a ColdFusion license....
I want to redirect any visits to those older files automatically to newer .php or .html files.
here's my question:
If a visitor clicks a search engine link pointing to one of the older files with the .cfm or .asp extension, is there a .php script way to redirect that visitor to the newer .php or .html files without having to place a redirect instruction on each of the files?
Any/all help much appreciated.
thanks.
michael
how to redirect on file type
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Have you looked into Mod Rewrite yet?
Off the top of my head you could try something like (untested)
However, I would probably set the 404 handler to send the permanent redirect header and redirect to the appropriate url. This will update the search engine listings to the correct page as well
.
Off the top of my head you could try something like (untested)
Code: Select all
RewriteEngine On
RewriteRule ^(.*?).asp$ $1.php
RewriteRule ^(.*?).cfm$ $1.php