Forum Moderators: phranque

Message Too Old, No Replies

url mod-rewrite question

apache webserver

         

ben_jamn

4:13 pm on Aug 22, 2007 (gmt 0)

10+ Year Member



Hi this is my first time doing this so I apologize if I don't get this right the first time.

In a nut shell, I am looking for some guidance in trying to redirect certian uri's to a servlet in an appserver without using the context root anylonger.

My current configuration works like this www.mydomian.com/ln/bmw (/ln being the context root in my plugin to a servlet running in a remote application server instance). The servlet then rewrites the request /ln/bmw to the actual site running in a content server. Note: We have hundreds of these rewrites setup using the servlet.
I would like to change the way this is currently accessed by removing the /lm/ in the request, so instead, to have, www.mydomain.com/bmw, but still forward to the servlet to be rewritten the same way. Because we have many rewrites, I don't think individual redirects on the webserver is even possible.
Is this task possible using a rewrite/rewriteCondition? I thought of using a Condition where a 404 error would rewrite to my servlet. In my example, www.mydomain.com/bmw would error with a 404 and rewrite to the servlet and load the actual site for /bmw. Is this a possibility? Also, once the 404 comes into play and rewrites to the servlet, how will the servlet know that the original request was /bmw? Can the /bmw be preserved in some way?
Is there an enterly diffewrent and better way to do this?
Thanks very much for your assistance.

g1smd

7:32 pm on Aug 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The original URL is held in {THE_REQUEST} if that helps.

jdMorgan

9:30 pm on Aug 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or, if you're not already using it, look sending requests to the back-end using mod_rewrite's [P] flag instead of a rewrite or redirect. You can pass any info you want to the back end as a query string.

The difficult part is determining which paths should be proxied and which should not. You need to develop a 'system' -- whether 'page'-based as in "/ln" or "/best-bmw," or perhaps even hostname-based, as in "bmw.example.com". Otherwise, the only option that won't seriously affect search ranking or server performance is a 'list' of URL-paths to be passed to the back-end -- And that list will have to be maintained over the long term.

Do not use a 404-Not Found handler for anything but unexpectedly-missing URL-paths; To do so is to destroy any chance your site might have at ranking in the search engines. This method was an old last-ditch "method of despair" used by Webmasters on ultra-cheap/free hosting, who had no other configuration-control options and used it as a "beggar's redirect." Search engines don't think much of sites that return 404s for almost every page request.... This method has no place in any serious endeavor.

Jim