Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • Last Modified:

IIS- how 2 auto-redirect mypage.htm to mypage.asp?

       I have over 40 .htm files and many cross links. I did a rename *.htm *.asp and now many links dont work.
I am including ASP code in each file to allow access. I dont want to go and replace htm with asp in each file.

        So i was wondering if there was a way to use IIS 5.0 (Windows 2000) to automatically load the corresponding asp file instead of the htm file?
  • 2
  • 2
1 Solution
you will need to use a URL re-write ISAPI filer that will convert each inbound request.

You could make a custom 404 error page (this page is beeing loaded if IIS cant find the requested file).

     'save this to file in the siteroot as 404.asp and configure your IIS to use for 404 errors.
     'righthclick the site name- >choose properties->cusomt errors.
     'scroll down the list until you find 404. Mark it and push Editproberties
     'Change the messageType to URL and the URL valuefield to /404.asp
     dim newFilename
     ' the querystring counld hold something like this
     ' 404;http://www.xxxxxx.xxx/tools/test.asp3
     'First remove the noise (404;http://)
     newFilename = replace(newFilename, "404;http://", "")
     ' findout which filethat was requested
     newFilename = right(newFilename, instr(newFilename,"/")-1)
     'find the last period in the filename
     newFileName = left(newFileName,instrRev(newFilename, "."))
     'brew the new filename
     newFileName =newFileName & "htm"


copy paste this into your favorit editor...

Best regards
excellent solution xaungxaj.....
Downside of the medal is that it will mess up the logfiles with a lot of 404 errors.

I've been looking for some urlrewritters myself.
I found this one which happens to be free too. That is if you doen't have to put different configurations for different sites. http://www.isapirewrite.com/

This one have the utilliy to "not mangle" with the log files...
Meaning if someone request xxx.sddsfds.xxx/folder1/folder1_2
then that is what that will be recorded in the logfile.
eventhough it's another file handling the request

iamkarthkAuthor Commented:
ThanX Xaungxaj

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now