IIRF Rewrite Condintion and Rewrite Rules

Topics: User Forum
Jul 18, 2012 at 5:34 PM

I'm re-writing a Coldfusion site in PHP. I just started learning about IIRF and how it works with IIS 6. For testing purposes, I want a rewrite condition that looks for specific .cfm files and (if they don't exist) re-writes them to corresponding .php files. Then, after the php re-write, I want to remove the file extention .php. I'm doing this to try to help with indexing and preserve a high SEO ranking. I'm OK at understanding regex, but no expert, so how would I write this in my .ini file?

Jul 19, 2012 at 12:10 PM

Probably best to post some examples of what you're trying to achieve.

It sounds as though, for SEO purposes, you want to redirect first, so that you're browser is showing the right URL and then rewrite to display the correct page.

Jul 19, 2012 at 8:16 PM

Here's an example of what I'm trying to do:

RedirectRule ^projects/valaonsnew/bill/newsletter05-01.cfm    projects/valoansnew/bill/newsletter05-01 [R=301]

RewriteRule ^projects/valoansnew/bill/newsletter05-01              projects/valoansnew/bill/newsletter05-01.php

I'm taking the previously named file .cfm and "rewrite" it as extension less with the 301 flag.  Then take the extension less file and make it look at the currently existing .php file with the same name in the same directory.

Jul 20, 2012 at 9:02 AM

It looks like you're most of the way there with those examples. You just need to plug in some group capturing now so that you don't have to type in all of these urls.

You should also look in to RewriteCond for checking against whether or not a file exists. That way you can redirect and rewrite as necessary.

There are some good examples in the documentation. Just shout if you need some more help.