Forum Moderators: phranque
I'm relatively inexperienced with mod_proxy and mod_rewrite, but I had this working in an Apache 1.x environment, but not quite behaving properly in an Apache 2.0 environment.
Hoping for some insight -- I'm certain it's not a major error on my part (or so I hope).
The following is the simple configuration from httpd.conf:
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ReWriteEngine on
RewriteRule (.*)\.cfm$ /cfm/$1.cfm [PT]
ProxyPass /cfm [other.server:82...]
ProxyPassReverse /cfm [other.server:82...]
Basically... What we want to do (and this works) is take force everything ending in .cfm to be routed to another server, and yet retain the appearance in the URL of our web server.
What's failing on us is pretty simple. If you specify the url:
[our.server...]
It behaves correctly. However, if you do a relatively common:
[our.server...]
instead, it won't work because it doesn't see it as something that matches the .cfm condition (even though the server will attempt to display the index.cfm file).
I know that rewriterule works on the full URL, though those worked in an earlier implementation of Apache. Is there a way to instruct RewriteRule (or something similar) to also catch "unspecified" .cfm hits, such as in the second example?
Appreciate the assistance...!
As for your question, the rule seems to be working properly. You need to rewrite the / url to /index.cfm url. Until you do that, the url is treated as / and your existing rule won't get to the proxypass.
The problem is that "/" can expand to anything defined in DirectoryIndex. For example:
/index.html
/index.htm
/index.php
/index.cfm
/moo.cow
...
Whatever. :-)
The problem here is that I need to capture everything that is *.cfm and redirect it to another server. This works like a charm when the user (or the URL specified in a link) includes the "/index.cfm".
Everything else is left untouched.
However, if the link or URL is simply "/", I can't capture it with the rewrite rules (at least not in any way that I am currently aware of), even though internally, apache will search through the DirectoryIndex possibilities until it gets a hit.
So rewriting "/" to "/index.cfm" will cause the link to fail on on all URL expansions that don't match that one particular possibility.
What I need to do is discover how to determine what Apache hit on from that list and -then- redirect it.
The only situation I'm having difficulty with is the case when there is only a trailing slash on URL... Everything else is working exactly like expected.
However, if the link or URL is simply "/", I can't capture it with the rewrite rules (at least not in any way that I am currently aware of), even though internally, apache will search through the DirectoryIndex possibilities until it gets a hit.So rewriting "/" to "/index.cfm" will cause the link to fail on on all URL expansions that don't match that one particular possibility.
The problem is that mod_dir will resolve the "/" request to a filename *after* mod_rewrite is finished processing. The only solutions I know of are to:
Jim
If so, I may actually have to consider downgrading the server from Apache 2 to Apache 1.3, where the process works -- What I'm encountering today is a change in the behavior of Apache 2 (not saying that Apache 1.3 wasn't doing it wrong :-), only that it was doing exactly what I wanted it to do).
We're looking at a large, and also widely distributed content management corporate server. While I'd personally like to see it be far more standardized than it is, it's not an option. :-(