Today is a good day to code

OS X Server and mod_rewrite

Posted: December 31st, 1969 | Author: | Filed under: Uncategorized | No Comments »

OS X Server and mod_rewrite

Picture of IrvinFor some time now I have been trying to get my URL rewriting under control with mod_rewrite on Mac OS X “Tiger” Server. Fortunately it comes as a preinstalled module with Apache 1.3, the default web server for OS X Server.

The first steps I tried were to edit my /etc/httpd/httpd.conf file to include the mod_rewrite rules, but they didn't work. So I set the RewriteLog variable to “/var/log/httpd/rewrite_log” and the RewriteLogLevel to 9. But I only saw my loopback pings trying to apply my rules.

Then I remembered that I was using Virtual Domains. I looked in my /etc/httpd/sites/ folder and saw that there was a conf file for each of my sites. I opened the one pertaining to the particular site that I wanted to make changes to, and added my rewrite rules in an rule. Once I did that, everything was working. It took a few times to get my regular expression to produce the proper result.

A word to the wise if you are using ColdFusion. All templates that are to be processed by ColdFusion need to end in .cfm. You can change that by going into your WEB-INF folder under JRun4 if you have an old installation, otherwise it would be under the /opt/coldfusionmx7/conf folder or something like that. What you are looking for is the web.xml or something. Inside you will find that you can define what extensions ColdFusion processes. Just look for .cfm in that file. You can add your own extension from the rewrite rule you just defined. In my case, I chose xhtml. So whenever ColdFusion sees a file with an .xhtml extension, it will try to parse it.

That was it, now I have properly formatted URLs.