Re: Keep WebObjects, Remove cgi-bin
Re: Keep WebObjects, Remove cgi-bin
- Subject: Re: Keep WebObjects, Remove cgi-bin
- From: Chuck Hill <email@hidden>
- Date: Mon, 25 Jun 2007 12:00:19 -0700
On Jun 24, 2007, at 6:50 PM, Joe Moreno wrote:
Hi,
Summary
I changed the apache.conf WebObjectsAlias from /cgi-bin/WebObjects
to /WebObjects to shorten the URL but the images broke when the app
was deployed.
Details
I looked through the WO archive to figure out how to remove cgi-
bin from the WO URL while keeping WebObjects, but I didn't find
anything to fix the broken images. I'm looking for a WebObjects
solution (vice an apache mod rewrite solution).
I'm close, though, when I changed the following apache.conf line
from:
WebObjectsAlias /cgi-bin/WebObjects
to:
WebObjectsAlias /WebObjects
This works great, but this also breaks the images in deployment.
The URL for the images doesn't change (Web server resources usually
aren't preceded with cgi-bin), here's a sample image URL for the
deployed app:
http://www.example.com/WebObjects/WoApp.woa/Contents/
WebServerResources/Go-Button.gif
After carefully clearing the browsers cache, I can see that the WO
app is generating the same image URL for both the cgi-bin/
WebObjects and /WebObjects configurations.
I have a test image (cnn.gif) here: docroot/WebObjects/cnn.gif
When I set the WebObjectsAlias to /cgi-bin/WebObjects, the Web
server has no problem serving up the image.
When I change the WebObjectsAlias to /WebObjects, the Web server
can't find the image.
It would seem that the WebObjects adaptor is intercepting the
request, since WebObjects is in the URL, but I don't know where
it's looking for the Web server resources. Permissions on the
WebObjects folder don't seem to be an issue.
Did I miss something when changing the WebObjectsAlias? (I also
changed the apache.conf's WebObjectsDocumentRoot )
Did you change the WOCGIAdaptorURL command line argument?
WOApplicationBaseURL?
See http://developer.apple.com/documentation/WebObjects/
WOAppProperties/AppProperties/chapter_1_section_1.html
Chuck
Miguel Arroz wrote:
Hi!
On 2006/10/10, at 21:50, Chuck Hill wrote:
Interesting I never tried that. Thanks for the tip! You just
have this then?
WebObjectsAlias /WebObjects
Yap! :) Taking the cgi-bin part out makes the URL look much
better!
Yours
Cool. Thanks for that info. I think that is definitely Wiki worthy
(if its not there already).
Sweet, it works like a charm !
Thanks for all.
____________
Thanks Chuck you saved the day yet again.
I took a look at http://www.jewelryluv.com/fashion/pageWithName/
ModRewrite/ but didn'tknow how to make it work with dynamic URLs so
I changed applications dispatchRequest as below.
However it doesn't seem to return the correct response.content()
the second System.out.println I do shows that it has been replace
but the generated page still contains the cgi-bin references?
public WOResponse dispatchRequest(WORequest request) {
if ("/favicon.ico".equals(request.uri())) {
return new WOResponse();
}
WOResponse response = super.dispatchRequest(request);
String contentType = response.headerForKey("content-type");
if ((contentType == null) || (contentType.toLowerCase().indexOf
("text/html") > - 1)) {
response.setContent( response.contentString().replaceAll( "/cgi-
bin/WebObjects/", "" ) );
System.out.println("WOResponse = " + response.contentString() );
return response;
}
return super.dispatchRequest(request);
}
Regards
David Elsner
Ph 61+02 42214251
On 09/03/2006, at 3:01 PM, Chuck Hill wrote:
Hi Dave,
On Mar 8, 2006, at 7:56 PM, Dave Elsner wrote:
I know this issue has been covered many times before but I still
can't seem to find a solution to:
How to remove the "cgi-bin/WebObjects/appName.woa" from the URL
permanently ?
I have set up Apaches modRewrite so I can navigate to the Domain
name, but as soon as I navigate from the front page the site the
URL goes back to using " cgi-bin/WebObjects/appName.woa" How came I
change the application so that all hyperlinks and form submit
return a URL like:
http://mydomain/appname.woa/blahblah that will be translated by
apache to http://mydomain/cgi-bin/WebObjects/appname.woa/blahblah
My rewrite rule would look some thing like: RewriteRule ^/
appname.woa.* /cgi-bin/WebObjects/appname.woa$1 [L,PT]
Can I do this in appendToResponce ? pageWithName? or changing the
Monitors path to the WO Adaptor?
In a nutshell, you have to generate the URLs yourself. There are
many ways of doing this:
1. Create a class that generates the URL and use this with the href
bindings on the components
2. Create a custom WOContext subclass to generate the URLS you need
3. Use regex to find and change the URLs in dispatchRequest in
Application (probably the best place)
4. Do something like this: http://www.jewelryluv.com/fashion/
pageWithName/ModRewrite/
Chuck
--
Coming in 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/
practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden