Newb Needs URL Rewrite Help

669 views
Skip to first unread message

Che Vilnonis

unread,
Jun 16, 2015, 10:58:53 AM6/16/15
to lu...@googlegroups.com
Hello all. On my dev machine, I have installed Lucee Express 4.5.1.020 final w/ Apache Tomcat/8.0.15 on Windows 7. I cannot get any url rewrites to work. I have tried Tuckey's urlrewrite filter and Tomcat's rewrite valve but my lack of Tomcat experience is hindering my efforts.

If possible, could someone reply with "newb" instructions on how to setup either of the above for Lucee Express? Other solutions are welcome.

The rewrites for the site aren't complex. I need to convert:

http://local.abc.com:8888/category.cfm?cat=the-sweet-life
-to-
http://local.abc.com:8888/category/the-sweet-life

Any help would be appreciated.

Thanks, CV

Mehdi B

unread,
Jun 16, 2015, 11:26:08 AM6/16/15
to lu...@googlegroups.com
If you plan to use IIS you can do that in IIS without rolling url rewrite on tomcat. Same all over apache use.

With apache you will use .htaccess rules and under IIS :


That would be far easier than toying with tomcat.

M B

Che Vilnonis

unread,
Jun 16, 2015, 11:31:32 AM6/16/15
to lu...@googlegroups.com
MB, yes I realize that, I'll be using Apache when the site is live.

That said, my goal is to not install additional software. I like the idea of simply copying a properly configured folder and having it simply just run on my work PC, home PC, laptop, etc.

That is why I am asking for help.

CV

Andrew Dixon

unread,
Jun 16, 2015, 11:48:36 AM6/16/15
to lu...@googlegroups.com
If you don't want to install additional software to mirror your production environment I would highly recommend you look at CommandBox then:


CommandBox's embedded Lucee server has Tuckey rewrites already enabled in it and you can create a customRewrites.xml file in your site root directory and then start the embedded server using:

start --rewritesEnable rewritesConfig=customRewrites.xml

This is all explained here:


However I have personally found Tuckey rewrites to be slightly limited in their capability and it is, from what I can see, a dead project.

Kind regards,

Andrew

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/37907aa0-0d95-4f88-9fa9-7c8ff72875f0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Igal @ Lucee.org

unread,
Jun 16, 2015, 11:57:55 AM6/16/15
to lu...@googlegroups.com
you can do it in 3 simple steps without any other software:

1) add a servlet-mapping for the CFMLServlet in web.xml (either in Tomcat/conf/web.xml for the whole server, or in /WEB-INF/web.xml for a specific web context):

  <url-pattern>/category/*</url-pattern>

pages like /category/the-sweet-life will have:

  CGI.SCRIPT_NAME == "/category"
  CGI.PATH_INFO   == "/the-sweet-life"


2) create a new file named "category" with no extension, alongside category.cfm, and in it something like:

  <cfscript>
      if (len(CGI.PATH_INFO) > 1) {
          URL.cat = mid(CGI.PATH_INFO, 2);    // remove leading '/'
      }
      else {
          // handle no category
      }

      include "category.cfm";
  </cfscript>


3) restart Tomcat for web.xml changes to take affect (not really a step, but 3 steps sounds better than 2 ;])

Igal Sapir
Lucee Core Developer
Lucee.org

Che Vilnonis

unread,
Jun 16, 2015, 11:58:11 AM6/16/15
to lu...@googlegroups.com
Thanks Andrew. TBH, I'm not trying to over complicate this. I just thought there might be instructions or a blog post that says edit this file in this directory, add this file here, etc. and voila I'd be up and running.

CV

Andrew Dixon

unread,
Jun 16, 2015, 5:57:21 PM6/16/15
to lu...@googlegroups.com
Seriously, try CommandBox if you don't want to over complicate it, once you try it you really will see what I mean, it makes things simple.

Kind regards,

Andrew

--
You received this message because you are subscribed to the Google Groups "Lucee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Jon Clausen

unread,
Jun 17, 2015, 10:08:05 AM6/17/15
to lu...@googlegroups.com

CommandBox is a good solution, IMHO, and you can have different ports and configurations for each app. I prefer it over using a single Lucee installation.

This rewrite should handle what you’re looking to do in Apache (provided you have a custom hosts entry for “local.abc.com” set to 127.0.0.1).

RewriteRule ^/([category])/([^/]+)$ http://local.abc.com:8888/category.cfm?cat=$2 [R]

You can also proxy all traffic except images or use a default route like “index.cfm” - here’s an example using a Coldbox index.cfm rule with the CommandBox server running on a custom port:

<Location />
    RewriteEngine on
    # Bypass images, css, javascript and docs, add your own extensions if needed.
    RewriteCond %{REQUEST_URI} \.(ttf|otf|woff2|woff|map|bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|ico)$
    RewriteRule ^(.*)$ - [NC,L,NS]
     
    #The ColdBox index.cfm/{path_info}:
    RewriteRule ^$ index.cfm [QSA,NS]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ http://127.0.0.1:57616/index.cfm/%{REQUEST_URI} [P]

    ProxyPass http://127.0.0.1:57616/
    ProxyPassReverse http://127.0.0.1:57616/
     
    SetEnv force-proxy-request-1.0 1
</Location>

HTH, Jon

Jon Clausen

unread,
Jun 17, 2015, 10:09:45 AM6/17/15
to lu...@googlegroups.com

Oops. That first example should be a [P], not an [R]:

RewriteRule ^/([category])/([^/]+)$ http://local.abc.com:8888/category.cfm?cat=$2 [P]

Che Vilnonis

unread,
Jun 17, 2015, 4:30:26 PM6/17/15
to lu...@googlegroups.com
Jon, Andrew & Igal thanks for your replies.

After even more time wasted, I decided to try CommandBox.
It took me a some time find my way... but I got my site running.
I even created my first "recipe" to save typing!

BTW, where are the Lucee server files stored?

Anyway, thanks again... it really is a well done product.

~CV
Reply all
Reply to author
Forward
0 new messages