Re: Writing an Apache 404 Handler in CF

2014-10-14 Thread Robert Glover

Hi Jon, thanks for the reply!

I'm far from an expert on Apache; in my httpd.conf, I don't seem to have any 
rewrite rules at all.  Where would I put these?  Inside the virtualHost section 
for my redirect app?

If it helps any, we're running Railo 4.2.1 on Tomcat 7, not sure if that 
affects the Apache config.

Thanks a bunch!

Rob


 You’ve likely got a rewrite rule passes everything that is not a 
 document to CF for handling. I’m guessing you have a friendly URL 
 setup that routes everything through index.cfm, which is why the 
 redirect is taking place.  Something like this is probably the 
 culprit:
 
 #These are handled by Apache and not by CF
 RewriteCond %{REQUEST_URI} \.
 (bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
 RewriteRule ^(.*)$ - [NC,L]
 
 #Everything else is handled by Coldfusion
 RewriteRule ^$ index.cfm [QSA,NS]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]
 
 If you change the rule for static files to include .aspx, then Apache 
 will handle that 404 as usual:
 
 RewriteCond %{REQUEST_URI} \.
 (aspx|bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
 
 HTH,
 Jon
 
 On Oct 10, 2014, at 4:34 PM, Russ Michaels r...@michaels.me.uk 
 wrote:
 
  
  Wouldn't url rewriting be better for this?
  
  
  On Fri, Oct 10, 2014 at 20:46 PM, Robert Glover sled...@gmail.com 
 wrote:
  
  
  This is as much an Apache question as it is a CF question; I hope 
 this is
  acceptable.  I posted it to Serverfault  several days ago and 
 haven't
  gotten any response, and it's become a rather critical issue.
  
  -
  
  I've written a custom 404 handler for Apache. The handler looks at 
 the
  incoming URL (cgi.request_url), queries a database table, and 
 responds by
  redirecting the visitor to the new URL. What should happen:
  
  www.mysite.co.uk gets redirected to www.mysite.com
  
  That much works fine. But when we get to more complex urls:
  
  www.mysite.co.uk/contact.aspx should go to www.mysite.com/contact/
  
  Something (Apache?) is stripping out the contact.aspx portion of it 
 so I
  can't tell where to send the user. In fact, what's happening instead 
 is
  contact.aspx is replaced with index.cfm (the name of the 404 
 handler). No
  other variables returned in the CGI scope contain the contact.aspx 
 part of
  the url.
  
  Of course, we have the domain to be redirected pointed at this 
 server via
  DNS, and configured in Apache, since the simple versions of the URL 
 work
  fine.
  
  Is there a configuration setting or something to get it to stop 
 stripping
  out the rest of the url? Thanks!
  
  Rob
  
  
  
 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359464
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Writing an Apache 404 Handler in CF

2014-10-10 Thread Russ Michaels

Wouldn't url rewriting be better for this?


On Fri, Oct 10, 2014 at 20:46 PM, Robert Glover sled...@gmail.com wrote:


This is as much an Apache question as it is a CF question; I hope this is
acceptable.  I posted it to Serverfault  several days ago and haven't
gotten any response, and it's become a rather critical issue.

-

I've written a custom 404 handler for Apache. The handler looks at the
incoming URL (cgi.request_url), queries a database table, and responds by
redirecting the visitor to the new URL. What should happen:

www.mysite.co.uk gets redirected to www.mysite.com

That much works fine. But when we get to more complex urls:

www.mysite.co.uk/contact.aspx should go to www.mysite.com/contact/

Something (Apache?) is stripping out the contact.aspx portion of it so I
can't tell where to send the user. In fact, what's happening instead is
contact.aspx is replaced with index.cfm (the name of the 404 handler). No
other variables returned in the CGI scope contain the contact.aspx part of
the url.

Of course, we have the domain to be redirected pointed at this server via
DNS, and configured in Apache, since the simple versions of the URL work
fine.

Is there a configuration setting or something to get it to stop stripping
out the rest of the url? Thanks!

Rob



~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359452
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Writing an Apache 404 Handler in CF

2014-10-10 Thread Jon Clausen

You’ve likely got a rewrite rule passes everything that is not a document to CF 
for handling. I’m guessing you have a friendly URL setup that routes everything 
through index.cfm, which is why the redirect is taking place.  Something like 
this is probably the culprit:

#These are handled by Apache and not by CF
RewriteCond %{REQUEST_URI} \.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$
RewriteRule ^(.*)$ - [NC,L]

#Everything else is handled by Coldfusion
RewriteRule ^$ index.cfm [QSA,NS]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.cfm/%{REQUEST_URI} [QSA,L,NS]

If you change the rule for static files to include .aspx, then Apache will 
handle that 404 as usual:

RewriteCond %{REQUEST_URI} \.(aspx|bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf)$

HTH,
Jon

On Oct 10, 2014, at 4:34 PM, Russ Michaels r...@michaels.me.uk wrote:

 
 Wouldn't url rewriting be better for this?
 
 
 On Fri, Oct 10, 2014 at 20:46 PM, Robert Glover sled...@gmail.com wrote:
 
 
 This is as much an Apache question as it is a CF question; I hope this is
 acceptable.  I posted it to Serverfault  several days ago and haven't
 gotten any response, and it's become a rather critical issue.
 
 -
 
 I've written a custom 404 handler for Apache. The handler looks at the
 incoming URL (cgi.request_url), queries a database table, and responds by
 redirecting the visitor to the new URL. What should happen:
 
 www.mysite.co.uk gets redirected to www.mysite.com
 
 That much works fine. But when we get to more complex urls:
 
 www.mysite.co.uk/contact.aspx should go to www.mysite.com/contact/
 
 Something (Apache?) is stripping out the contact.aspx portion of it so I
 can't tell where to send the user. In fact, what's happening instead is
 contact.aspx is replaced with index.cfm (the name of the 404 handler). No
 other variables returned in the CGI scope contain the contact.aspx part of
 the url.
 
 Of course, we have the domain to be redirected pointed at this server via
 DNS, and configured in Apache, since the simple versions of the URL work
 fine.
 
 Is there a configuration setting or something to get it to stop stripping
 out the rest of the url? Thanks!
 
 Rob
 
 
 
 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:359453
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm