stuck in URL rewriting

Topics: Developer Forum, Project Management Forum, User Forum
Mar 23, 2011 at 11:48 AM

I'm working on a website

Now I want to rewrite the URL for SEO: has to become -->


I'm so stuck in this

Can somebody assist with this please

Kind Regards,


Mar 23, 2011 at 10:19 PM

Gianni, I suggest that you use a RewriteMap directive, and then use a text file to create the mappings.  The text file would simply look like this:

# Map file for ipad2belgie
nieuws/ipad-2-will-it-blend/  index.cfm?pid=853&newsID=565
release                       index.cfm?pid=852

...and so on.  You can have as many mappings as you like. Each one on its own line.

If the text file is stored at c:\directory\urlmapfile.txt, the iirf.ini file would look something like this:

RewriteMap urlmap txt:c:\directory\urlmapfile.txt
RewriteCond ${urlmap:$1|NotFound}  !NotFound
RewriteRule ^/(.*)    /${urlmap:$1}


Mar 25, 2011 at 8:50 PM



I don't get out of it!

Breaking my head over it already 4 days!

Can I find a manual or some help from somebody please..

Thx so much gianni

Mar 26, 2011 at 7:04 AM

yes, the documentation is available online or on the downloads page.



Mar 26, 2011 at 2:22 PM
Edited Mar 26, 2011 at 4:20 PM

I already managed to rewrite ----------------> ------>

this is my iirf.ini file

RewriteEngine ON
StatusInquiry ON RemoteOk

RewriteCond %{HTTP_HOST}     ^ [I]
RedirectRule ^/(.*)$$1     [R=301]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-d [NC]

RewriteRule ^/(.*)/(.*)/$      /index.cfm?pid=$1&newsID=$2    [I,L]
RewriteRule ^/(.*)/$          /index.cfm?pid=$1    [I,L]

# END OF .ini

Is it now possible to rewrite like this: ----------> ------>

And get release, nieuws, ipad-2-will-it-blend, ... out of the database????

or is it possible toget the page title (in database) in url??


This .cfm file gets the pageid (pid)  from a table in my DB. In this table i have also a title column.
How can I make a the iirf file so I can have my title as the url eg: or

And the news pages gets the newsid (newsID) from an other table in my DB; In this table I have als a title column
How can I make a the iirf file so I can have my title as the url eg: or

I don't want to add each news item seperately into an urlmapfile.txt file. How can I accomplish this and how can I get php to remove all weird symbols etc... from my url title?

Looking forward to your answers! :)

Thx for your help aready

Regards Gianni

Mar 27, 2011 at 7:51 PM

just for purposes of discussion, I could imagine doing what you want this way:

A URL arrives at the server.  Some custom logic - let's not talk right now about where that logic might reside or how it would actually be installed into the IIS server - extracts the query path from the URL, and then performs a lookup in your database, looking for a record that contains a title that matches the query path. This logic then extracts the the pid and newsID for that given title.  It then rewrites the URL in the IIS server to the index.cfm page with the appropriate pid and newsID.  The appropriate page content is then emitted. 

I think that's what you are imagining.

In IIRF, for the RewriteMap directive, there is just one "map type": txt, which represents a text file.  In other words, it can only get the url-to-url mapping information from a text file. Well, not actually true, there is also a "rnd" type of map (see the documentation). But this still gets its data from a text file.  In the Apache mod_rewrite module, there is a map "type" called "pgm", which allows you to write custom logic to perform the mapping. This type of "RewriteMap" data source isn't supported in IIRF.  So the way to do this kind of thing in IIS/IIRF is to make the relevant title-to-URL mapping information into a text file.

One way to do what you want, let's call it "option (A)", is to auto-generate the text file using a simple database client app, that scans your article table and then just writes that text file.  you could easily write such a tool using CFM or PHP or VB.NET or C# or some other programming environment.  And then, using the Windows schtasks tool, you could schedule that program to run periodically - every hour? every 4 hours? every day? and re-generate the text file that contains up-to-date mapping information. Every time you posted a new article, the map file I described in my first answer (above) would get refreshed or re-generated by this simple app that you'd have to write. 

Another option here - option (B) - is to use a dedicated custom .cfm page to emit the article.  In this case, you would, using IIRF, rewrite ALL requests that do not have pid/newsID query parameters to an "title_lookup.cfm" page.  Think of this like a wildcard-handling cfm page, which would perform the database lookup I described above. In fact it works similar to your existing index.cfm page, except, whereas index.cfm uses the pid/newsID to perform database lookups and emit the article, the "title_lookup.cfm" would perform db lookups based on the title. You'd pass the original query path, which is also the title, as a query param to the custom page.  When it finds a record in your newsitem table in the db with matching title, that "title_lookup.cfm" page can just read the db record and emit the page content in the same way index.cfm does.

This is trickier because probably there are characters that are legal in "titles" that are not legal in URL query paths.  So your title_lookup.cfm page would have to be smart about that.  There are ways to work around this.  One way is to generate a table in the db with the URL-ized title, then do the lookup on that URL-ized version of the title. This table would need to get updated every time you post a new article. There are other ways of handling this issue too. The key for option (B) is that you need to be handy writing custom cfm, and maybe with custom db tables.