Railo w/ Apache 2 + mod_rewrite

So there have been questions about weather or not bluApple would run on Railo w/ Apache and mod_rewrite. I have tested it on Railo w/IIS and ISAPI ReWrite but I had not had any resources to do an install and test it our on Apache and mod_rewrite. So thanks to Master!Merlin of http://www.Dangerous-Minds.net I was able to test this out last night.

A little bit about D$M. "Dangerous Minds is a group dedicated to helping people and teaching them and ourselves." which was founded some time ago and is always a great place to get help on just about anything.

So a day or two ago Merlin, whom is a good friend of mine, and I spoke and I explained to him that I would like to get bluApple tested out on Railo w/Apache. So he set out on a mission to get Railo and apache setup on D$M. Yesterday he came to me and surprised me with "your server is ready" I installed bluApple on a domain that I had pointed there which is up and running. It is a standard install of bluApple and can be viewed at http://demo.bluApple.net.

So upon this venture we came across a few issues.

1. Merlin had some trouble getting railo and apache to install with virtual hosts. If your a linux / apache guru this should be no trouble at all. I am going to attempt to get Merlin to guest blog about it here.

2. Once bluApple was up and running I begun to test out the .htaccess file for bluApple. Of course it was not working because ISAPI_ReWrite had a few switches that were not recognized. So Here are some changes I made.

#===========================================================
# ISIAPI REWRITE SETTINGS
#===========================================================
   RewriteEngine On
   #RewriteCompatibility2 On
   #RepeatLimit 32
   RewriteBase /
#===========================================================
#===========================================================

As you can see above I commented with a "#" sign the two attributes. They were causing a problem initially.

Secondly. I had to change all of the paths. For some reason mod_rewrite does not like the "/" in front of the URL path when evaluating. If anyone knows why, I would love to have an official explanation of it.

Here is a couple examples of the change. Don't worry. I will be providing a new .htaccess file that is for mod_rewrite. But Just so your aware of the changes I am putting it below.

Example of the login rewrite in it's original form.

RewriteRule ^/Login$ /index.cfm?ba=f_login [L,NC]

RewriteRule ^Login$ /index.cfm?ba=f_login [L,NC]
Notice that I removed the "/" in front of Login$. This needs to be done for all RewriteRules. It will not throw an error if the "/" is present. However, it won't Rewrite the URL if you don't remove it.

The third thing is super simple. The switch 0 is not a valid switch in mod_rewrite. So You have to remove it from the security RewriteRule's. That section should now look like this.

#===========================================================
#Security
#===========================================================
   #Block external access to the httpd.ini and httpd.parse.errors files
   RewriteRule ^/httpd(?:\.ini|\.parse\.errors).*$ / [NC,F]
   
   #Block external access to the Helper ISAPI Extension
   RewriteRule ^.*\.isrwhlp$ / [NC,F]
#===========================================================
#===========================================================

Lastly, and really the by far the biggest issue is the RewriteMap. Here is the scoop.

The RewriteMap rule in ISAPI_ReWrite is allowed to be inside your .htaccess file. However, in Mod_Rewrite it is not. it has to be in your httpd.conf file. Which, i've heard is for some stupid security reason. I hate it when two technologies do things similar but not the exact same. It makes life a living hell. So Really, I have not found an adequate fix for this yet. Below are your options.

Option 1. You can comment out the RewriteMap Rule all together and create individual RewriteRules for each individual Meta Page created by the "Pages Admin" in bluApple.

This is how you would do that:

First Comment out the RewriteMap code.

#===============================================================================
# Rewrite Map to a generated isapi_lookup file.
#===============================================================================
#RewriteMap menumap txt:isapi_lookup.txt
#RewriteCond (${menumap:$1|}) ^.+$
#RewriteRule ^(/[a-zA-Z0-9_-]+)$ ${menumap:$1}? [NC,L]

Next open your mapping file (and this might change in the future to rewrite.maps) isapi_lookup.txt In that file you will see code that looks similar to the following:

/Home      /index.cfm?ba=mp&id=15
/Contact-Us      /index.cfm?ba=mp&id=24
/Contact-Thank-You      /index.cfm?ba=mp&id=26
/Test-Page      /index.cfm?ba=mp&id=27

For each entry in the mapping file. Do the following RewriteRule in your .htaccess file. I will use /Home as the example here.

RewriteRule ^Home$ /index.cfm?ba=mp&id=15 [L,NC]

By Creating individual RewriteRules, which is tedious if you have a lot of meta pages. Your meta pages will function properly with the friendly SEO URLS.

Option 2. You could open up the httpd.conf or have a system administrator edit this file and place a RewriteMap To your mapping file.

RewriteMap [yourmapname] txt:/path/to/file/isapi_lookup.txt

Once this line is in the httpd.conf file you can enable the following rules.

RewriteCond (${[yourmapname]:$1|}) ^.+$
RewriteRule ^([a-zA-Z0-9_-]+)$ ${[yourmapname]:$1}? [L,NC]

Well, that is all I got for you guys for now. I hope this information helps. I am looking for the best solution possible and as soon as I find one I will patch bluApple accordingly. Until then I will release an .htaccess file for mod_rewrite that I know works. Which should be available in the next day or two.

If anyone has any ideas or information on how to get the rewritemap into the .htaccess file, then I am open for suggestion.

until the next blog. /Marco

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress