Not sure if this is a lucee issue or an apache iss...
# lucee
s
Not sure if this is a lucee issue or an apache issue but does anyone have an idea why the following would not work System • aws linux 2 • apache httpd 2.4.57 • lucee 5 Website is being served as the default site from apache attempting to utilize url rewrite for seo urls for FW/1 .htaccess file contains the following
Copy code
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) /index.cfm/$1
If I hit tomcat directly using the seo url https//{mydomain}8888/features I see the features page normally. If I hit apache using non seo url http://{mydomain}/?action=features I also see the features page normally. But If I hit apache using the seo url http://{mydomain}/features I get a 404 and 'Not Found The requested URL was not found on this server.' My httpd.conf file contains
Copy code
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.cfm index.html
</IfModule>

<IfModule proxy_module>
        ProxyPreserveHost On
        ProxyPassMatch ^/(.+.cf[cm])(/.)?$ <http://127.0.0.1:8888/$1$2>
        ProxyPassMatch ^/(.+.cfml)(/.)?$ <http://127.0.0.1:8888/$1$2>
        ProxyPassReverse / <http://127.0.0.1:8888/>
</IfModule>
Been banging my head on this and I dont see why this is not working for me
b
Is the 404 you see coming from Apache or Lucee?
s
If I brute force it I can make it work eg
Copy code
RewriteRule ^features /index.cfm?action=features
But I dont want to have to do that for every action
b
Also, is there a real folder called
features
in your web root?
s
I think its apache
No, its a FW1 application action
b
If it's apache, then that means the rewrite isn't firing
So I'd troubleshoot there. It seems your only condition is the file exists check
Is the rewrite prior to the proxy?
s
I dont know
Its a standard lucee install on apache.
Using mod_proxy
b
Well, the standard install doesn't come with any rewrites that I know of
So if there are rewrites, then I assume you added them
s
Correct, the rewrites are in a .htaccess file
b
If your "brute force" rewrite that works is in the same location, then it's safe to say they're running before the proxy
What if you take the
Copy code
RewriteCond %{REQUEST_FILENAME} !-f
off as a test
Does your generic rewrite rule run then
If so, we know the issue is the condition
s
No effect with or without
b
Hmm, so
Copy code
RewriteRule ^features /index.cfm?action=features
works, but
Copy code
RewriteRule ^(.*) /index.cfm/$1
doesn't?
r
Would this help?
Copy code
sudo a2enmod rewrite
The command activates the module or—if it is already activated, displays the words, "Module rewrite already enabled"
b
Unless your proxy pass regex isn't matching
Copy code
^/(.+.cf[cm])(/.)?$
actually, I think that may be it
That regex doesn't seem like it would match at all at first glance
It's looking for
/something.cfm/
(or
/something.cfc/
) and then a single character?
Am I reading that right?
Ahh, there is a
?
after so I think the trailing slash is optional but that still doesn't seem right
you'd need the proxy to match
/something.cfm/anything/here/forever
s
hmmm 🤔
b
Using an online regex tester,
Copy code
^/(.+.cf[cm])(/.)?$
does not match
Copy code
/index.cfm/features
So I would assume that's why it's not being proxied
I would adjust the proxy regex and it should start working fingers crossed
r
yeah it only allows for matching both
/filename.cfc
and
/filename.cfc/a
, for example.
s
👀
r
/filename.cfc/asdf
would not work
^/(.+.cf[cm])(/.*)?$ might work
ah, Brad has it already above! Lol I missed that comment. Close to mine, that is. Mine has an asterisk toward the end as the difference it looks. This is if you are looking for optional pathing after the optional last slash
s
No joy, I've tried every combination. Going to take a break and try again this evening
Finally cracked it For those curious. It was a combination of new mod_proxy and .htaccess
Copy code
<IfModule proxy_module>
        ProxyPreserveHost On
        ProxyPassMatch ^/(.+.cf[cm])(/.*)?$ <http://127.0.0.1:8888/$1$2>
        ProxyPassMatch ^/(.+.cfml)(/.*)?$ <http://127.0.0.1:8888/$1$2>
        ProxyPassReverse / <http://127.0.0.1:8888/>
</IfModule>
Copy code
Options +FollowSymlinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI}% !^/index.cfm
RewriteRule ^(.*) /index.cfm/$1 [L]
🍻 2