Angel has asked for the wisdom of the Perl Monks concerning the following question:

Just when I think I am getting good at perl I get stumped again. I have found little on mod_rewrite here and I figure I am not the first to use mod_rewrite with perl for hiding the cgi and I wont be the last. So this is kinda off topic but I feel is relevant.

Thus I ask for your help as best as possible. If the behavior from the mod_rewrite is what I should expect from the third example ( earthlink ) please tell me so. I am hoping that it's just earthlink being lame ( and my employers instance on using them ) and that the Panix account is an example of what mod-rewrite is supposed to do.

We are creating dynamic websites that create ica files that enable citrix connections to our client schools as well as generating instructional websites that allow them to install the client.

My previous version ( example 1 ) we created a dummy directory and put a redirect that points to a cgi script. The disadvantage of this is that the children get confused and some of the spam blocking software at the school will block redirects (which is not under our control) in addition the ica file does not download correctly as a cgi script under netscape and thus many of the students cannot get on. In addtion dynamically generating directories to do this is messy and is not an elegant solution.

example 1 http://www.classlink2000.com/sites/bethpage

My solution was to use mod_rewrite and move our site to earthlinks Atlanta platform which they said would do such a thing after testing my idea was viable on a server equipped with the module. This works fine on Panix and the end user never knows its dynamic.

Example 2 http://www.panix.com/~hamilton/DEVELOPMENT/DBSITES/bethpage
NOTE Example only has the main page and ICA working

On the earthlink server I tested my scripts and am getting odd results. I worked on getting any scripts to work with the code but it seems the REQUEST_URI is set to the redirected URI after the mod rewrite is processed. So I then tested pushing the needed arguments using $1 and $2 with this rewrite ( bottom of post ) And achieved the desired rewrite but the url bar on the top of IE shows: http://w0105637.w1.net/DB_STEALTH/env_test.cgi?a=bethpage&b=index defeating the entire purpose of this exercise. This is not present on my non-earthlink example and I would appreciate any advice you could give me to getting the rewrite to be as it is in my working panix example.

example 3 http://w0105637.w1.net/DB_STEALTH/bethpage/index.html

turns into: http://w0105637.w1.net/DB_STEALTH/env_test.cgi?a=bethpage&b=index

RewriteRule ^([^/]+)/([^/]+).html$ http://w0105637.w1.net/DB_STEALTH/e +nv_test.cgi?A=$1&B=$2

Thank you for your help in advance

Replies are listed 'Best First'.
Re: mod_rewrite and hiding perl
by ant9000 (Monk) on Jul 09, 2003 at 17:16 UTC
    Did you configure Apache yourself? As far as I can tell, in the example 3 it seems that Apache is configured with
    RewriteRule ^([^/]+)/([^/]+).html$ http://w0105637.w1.net/DB_STEALTH/e ++nv_test.cgi?A=$1&B=$2 [R]

    instead of the rule you show (the final [R] does exactly a "public" redirect). BTW, I'd use a [L] to say this is the last rule for this URI.

      Yeah thats the problem they seem to have [R] set by deafult and I was just wondering if I was missing something. ( like how to override it ) I tried another help site but as you can see with all the other questions I have posted you guys are amazing at answering my questions and I am pulling my hair out. Plus I know I wont be the only perl geek to get this to work

      I called my ISP for support and their second tier support guy said he might be able to look into it in a 4-8 weeks. Is that great or what?

Re: mod_rewrite and hiding perl
by Tomte (Priest) on Jul 09, 2003 at 18:57 UTC

    Not exactly sure if this will work in your situation, but hiding where you are redirecting to is normaly easily done using [L,P] instead of [R], telling mod_rewrite to proxy the request (you need mod_proxy as well, but they both should be present in a n apache-installation).
    Additionaly ProxyPassReverse statements may be necessary if your script issues redirects, letting the proxying apache rewriting given urls on the fly before passing the redirect through to the client.

    Additionaly you should check if the available CPAN modules (e.g. Apache::ProxyRewrite) could do the job better, if mod_perl is present.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.