mod_rewrite- Redirecting w/o changing URL?

mod_rewrite- Redirecting w/o changing URL?

Post by su.. » Tue, 02 May 2000 04:00:00



Hi! I'm trying to use mod_rewrite to do a redirect on any file
underneath host/users/ folder. I can do the redirect using:

Rewri*gine On
RewriteRule ^/users/ /my.jsp?path=%{SCRIPT_FILENAME} [R,L]

but in the location bar, it says my.jsp?path=whatever

I've been told that I can tell apache to load module/cgi whenever it
hits the users folder, which preserves the URL? Is mod_rewrite the
direction to pursue?

Any advice would be fantastic!
Thanks!
Susan

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

mod_rewrite- Redirecting w/o changing URL?

Post by Joshua Sliv » Tue, 02 May 2000 04:00:00



> Hi! I'm trying to use mod_rewrite to do a redirect on any file
> underneath host/users/ folder. I can do the redirect using:
> Rewri*gine On
> RewriteRule ^/users/ /my.jsp?path=%{SCRIPT_FILENAME} [R,L]
> but in the location bar, it says my.jsp?path=whatever
> I've been told that I can tell apache to load module/cgi whenever it
> hits the users folder, which preserves the URL? Is mod_rewrite the
> direction to pursue?

Perhaps you should consult the docs to see the effect of the
[R] option.  I believe it is doing the oposite of what you
want, and should be removed.

--
Joshua Slive

http://www.veryComputer.com/~slive/

 
 
 

mod_rewrite- Redirecting w/o changing URL?

Post by bajich.. » Tue, 02 May 2000 04:00:00


Quote:> > Rewri*gine On
> > RewriteRule ^/users/ /my.jsp?path=%{SCRIPT_FILENAME} [R,L]
> Perhaps you should consult the docs to see the effect of the
> [R] option.  I believe it is doing the oposite of what you
> want, and should be removed.

Thank you so much for responding! I really appreciate it as I'm
floudering through my first foray into the guts of Apache. :)

I tried taking out the [R] option, and the browser simply hangs, with no
information in the error_log file. I agree that the redirect wouldn't
accomplish what I want, when my goal is the keep the initial URL
visible, and cloak the redirect URL.

All of the other flags for RewriteRule seem to be concerned with
ordering through different sets of rules, and don't seem useful to me.
Do you think that RewriteRule is the way for me to go?

I am also trying to use the <Location> synatax:

<Location /users/>
     allow from all
     Options ExecCGI
     SetHandler cgi-script
     #SetHandler /cgi-bin/user_handler.cgi
</Location>

Under my user folder, I have a .htaccess file that says
SetHandler /cgi-bin/user_handler.cgi

But unfortuneatly, I get the normal 404 error when I type in a filename
underneath the user folder, and in the error_log it says "can't find or
start script for /users/susan/xxx.html"

I get the feeling I'm not using the <Location> directive or the
.htaccess file directive correctly... :)

Several people have told me that mod_rewrite is the way to solve this
problem. And yet, the more I study the flags, it doesn't seem that its
possible to preserve the existing URL and display different content? But
I know that truely zippy folks do it all the time!

Any advice would be great!
And thanks again for responding.
Susan

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

mod_rewrite- Redirecting w/o changing URL?

Post by Joshua Sliv » Tue, 02 May 2000 04:00:00



>> > Rewri*gine On
>> > RewriteRule ^/users/ /my.jsp?path=%{SCRIPT_FILENAME} [R,L]
>> Perhaps you should consult the docs to see the effect of the
>> [R] option.  I believe it is doing the oposite of what you
>> want, and should be removed.
> Thank you so much for responding! I really appreciate it as I'm
> floudering through my first foray into the guts of Apache. :)
> I tried taking out the [R] option, and the browser simply hangs, with no
> information in the error_log file. I agree that the redirect wouldn't
> accomplish what I want, when my goal is the keep the initial URL
> visible, and cloak the redirect URL.

You haven't been very specific about what my.jsp is.  If it is
a CGI script, then you may need to add the [PT] flag to get
processing to pass through to the cgi module.

Quote:> I am also trying to use the <Location> synatax:
> <Location /users/>
>      allow from all
>      Options ExecCGI
>      SetHandler cgi-script
>      #SetHandler /cgi-bin/user_handler.cgi
> </Location>
> Under my user folder, I have a .htaccess file that says
> SetHandler /cgi-bin/user_handler.cgi

I think you are looking for the Action directive:
http://www.veryComputer.com/#action

--
Joshua Slive

http://www.veryComputer.com/~slive/

 
 
 

mod_rewrite- Redirecting w/o changing URL?

Post by su.. » Tue, 02 May 2000 04:00:00


It works! It works! :) :) :)

Thank you so much for responding! I changed my rewrite rules to:

Rewri*gine On
RewriteRule ^/users/ /usr/local/httpd/cgi-bin/user_handler.cgi

This redirects to a.cgi and with no [R] flag, it doesn't change the URL!
Within the cgi, I use hidden frames:

print "<frameset rows='100%,*' framespacing='0'>";
print "<frame name='frameMain' src='$new_url' scrolling='no'>";
print "<frame name='frameHidden' src='' scrolling='no'>";
print "</frameset>";

where $new_url is constructed based off of the global environment
variables available to the shell script! And because I'm using frames,
the URL still doesn't change! Kind of a cheat, maybe... but it works and
I'm really happy!

Thanks again for your time, help and patience. Now I know all kinds of
things about Apache guts!

Take Care!
Susan

Sent via Deja.com http://www.veryComputer.com/
Before you buy.