Lucee Not Reading htaccess File for SES Urls

I recently installed Lucee on Windows using the installer “lucee-5.4.5.23-windows-x64-installer” and am testing a website that previously ran using Coldfusion.

Everything works well, except that the htaccess file isn’t being read, which handles the Search Engine Safe (SES) Urls. Previously the URL mywebsite.com/profiles would translate to mywebsite.com/index.cfm?do=profiles using the htaccess rule:

RewriteRule ^([A-Za-z0-9-]+)/?$ index.cfm?do=$1 [NC,L]

Currently, if I run http://127.0.0.1:8888/mywebsite/profiles, it gives the error

HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/mywebsite/profiles] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/9.0.86

However, if I run the page http://127.0.0.1:8888/mywebsite/index.cfm?do=profiles it does work as expected.

This leads me to believe that the htaccess file isn’t being read/seen. I have tested this by adding some garbage to the htaccess file to see if it would cause the website to error, but it does not. So this file appears to be being ignored/bypassed.

Is there anything else I have to do since installing Lucee to get this to work properly? At my Lucee webhost (Vivio), the htaccess file is detected and works perfectly. So it’s just my local machine with this new installation of Lucee that seems to missing something. I checked the docs at: Configuring SES URL's on Windows OS's :: Lucee Documentation but this only seems to apply to older versions of Lucee.

So I’m not sure where to go from here. Any help would be appreciated.
Thanks.

OS: Windows 10 (10)
Java Version: 11.0.22
Tomcat Version: 9.0.86
Lucee Version: 5.4.5.23

Yes, .htaccess are Apache Web Server files, not Tomcat.

If you want to continue using Tomcat as rewrite engine, you should use Tuckey URLRewriteFilter addon.

Here is the documentation:

It’s quite simple to set up.

If you have problems, ask again.

HTH

1 Like

Thanks. The download link appears to be down. Does it work for you?
http://central.maven.org/maven2/org/tuckey/urlrewritefilter/5.1.3/urlrewritefilter-5.1.3.jar

https://tuckey.org/urlrewrite/

Doesn’t work for me. Same error that I posted a screenshot of above.

Could be, you…

https://repo1.maven.org/maven2/org/tuckey/urlrewritefilter/5.1.3/urlrewritefilter-5.1.3.jar

1 Like

Your link worked just fine. Thank you! Not sure why the original link doesn’t. I’ve tried turning off VPN and using different PCs to no avail.

I’m following the installation instructions. As soon as I add the FILTER code to the web.xml file, the website and Lucee admin break with the message below. I would expect that my website and the Lucee admin websites should still run as normal after adding the Filter. If I remove the code from the web.xml file, it runs as per normal again. So something about this is breaking the normal processing of the websites. Any ideas? Thanks

" HTTP Status 404 – Not Found

Type Status Report
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Apache Tomcat/9.0.86"

This is the code:

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
        <init-param>
            <param-name>logLevel</param-name>
            <param-value>DEBUG</param-value>
        </init-param>
        <init-param>
            <param-name>confReloadCheckInterval</param-name>
            <param-value>1</param-value>
        </init-param>
        <init-param>
            <param-name>confPath</param-name>
            <param-value>/WEB-INF/urlrewrite.xml</param-value>
        </init-param>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

this file exists?

It does. If I include it in the WEB-INF folder, this is the error I get:

The reason for this error is because the path it’s trying to access is this:
C:\lucee\tomcat\webapps\ROOT\hugirls\lucee\admin\web.cfm
but should be this:
C:\lucee\tomcat\webapps\hugirls\lucee\admin\web.cfm

I’m not sure how it’s getting that extra “ROOT” part.
The same happens if I try and access the website:
Page /hugirls/index.cfm [C:\lucee\tomcat\webapps\ROOT\hugirls\index.cfm] not found

Maybe the urlrewrite file is causing this, but I would expect it not to break the website or Lucee admin.

This is the contents of the urlrewrite file based on the docs that I got it from:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 5.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite5.0.dtd">

<!--

    Configuration file for UrlRewriteFilter
    http://www.tuckey.org/urlrewrite/

-->
<urlrewrite>

    <rule>
        <note>
            The rule means that requests to /test/status/ will be redirected to /rewrite-status
            the url will be rewritten.
        </note>
        <from>/test/status/</from>
        <to type="redirect">%{context-path}/rewrite-status</to>
    </rule>

    <outbound-rule>
        <note>
            The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
            the url /rewrite-status will be rewritten to /test/status/.

            The above rule and this outbound-rule means that end users should never see the
            url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks
            in your pages.
        </note>
        <from>/rewrite-status</from>
        <to>/test/status/</to>
    </outbound-rule>

</urlrewrite>

I strongly suspect that you need to add a Tomcat context directive with the value path=“hugirls” to your setup. Where to add it, depends on your setup. That would be through server.xml (old style) or adding a tomcat context file to /pathToLucee/tomcat/config/catalina/domain-name-,of-your-site/hugirls.xml.

Could you please elaborate on this. I have zero experience with Tomcat and was simply looking for a “simple” way to get SES Friendly urls to work, which is turning out not to be the case with this plugin.

Thanks

  1. Backup everything so you can always rolback.
  2. Open Tomcats server.xml.
  3. Find the Host entry that is setup for running your site.
  4. Add the context like so:
<Host ...>
    <Context path="/hugirls" docBase="/path/to/your/cfmfiles" />
    <!-- Other contexts or default context --
</Host>

Th en restart Tomcat

Thanks andreas, but that didn’t work. The same error as before occurs. (see the yellow lucee dump above)

@ Roberto_Marzialetti Would you mind stepping in and helping here please. You suggested the tag, so you may know why it isn’t working.

check the permissions on the added / changed files and file paths.

ls -lt