httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Csaba Gabor <csaba2...@yahoo.com>
Subject Re: Can I avoid an implicit redirect?
Date Mon, 24 Jun 2002 15:01:17 GMT
Well I figured out the answer, even if I don't quite understand it.  The docs explicitly say
that I shouldn't be getting an external redirect in the first place but there it is.  There's
not much apache post processing directives going on, just a Directory Index so apache can
figure
out that it should execute index.php.

The fix:  replace my last rewrite line with (the L from before was not needed):
RewriteRule (.*) /index.php$1 [NS,PT]
This line (in fact, this entire RewriteRule section) is needed since AcceptPathInfo doesn't
check for the default files to serve (index.htm, index.php, etc.)  If it did, none of the
rewrites would be necessary.

A variant on this, which had the same problems until that PT was inserted is
RewriteRule ^/(.*)$ /?PI=$1 [QSA,NS,PT]
this variant doesn't rely on PATH_INFO, and contrary to the Apache docs it prepends that PI=$1
instead of appending it to the existing query string.  I think we could get rid of the
AcceptPathInfo using this method, but then the following line should be revamped.
RewriteRule ^/index.php/ - [NC,L]

    Csaba

--- Csaba Gabor <csaba2000@yahoo.com> wrote:
Here I am with Apache 2, PHP 4.2, Windows 2K, and a problem.  I have a site with main page
http://mydomain.us/index.php and there are a few other top level pages and files.  Almost
everything goes through index.php and I'd like to tidy up some of my links so that instead
of
mydomain.us?Query=BigUglyThing&Goes=OnForever I can write something like
mydomain.us/key1/val1/key2/val2/you/get/the/idea

So I appeal to the handy, dandy ModRewrite and come up with something like (perhaps I could
get
rid of some lines):
    RewriteRule ^/?$ - [L]
    RewriteRule ^/\? - [L]
    RewriteRule ^/[^/.]*\.(php|js|htm)(\?|$) - [NC,L]
    RewriteRule \.(gif|jpg)$ - [NC,L]
    RewriteRule ^/index.php/ - [NC,L]
    RewriteRule ^(.*)$ http://mydomain.us/index.php$1 [NS,L]

Only that final line does any rewriting, and this works (putting the extra information into
PATH_INFO), I get the page, and life is good.  But, oh no! The address in the browser window
has
changed (same change happens even if prefixed with http://) from mydomain.us/this/is/a/test/
to
http://mydomain.us/index.php/this/is/a/test/
This is ugly.  And unfair.  OK, maybe that's going overboard, but I don't want it.

The culprit is that last RewriteRule line and the logfile says:
1.2.3.4 - - [23/Jun/2002:22:55:34 --0500] [MyDomain.us/sid#53e688][rid#56f7f0/initial] (3)
applying pattern '^(.*)$' to uri '/this/is/a/test/'
1.2.3.4 - - [23/Jun/2002:22:55:34 --0500] [MyDomain.us/sid#53e688][rid#56f7f0/initial] (2)
rewrite /this/is/a/test/ -> http://mydomain.us/index.php/this/is/a/test/
1.2.3.4 - - [23/Jun/2002:22:55:34 --0500] [MyDomain.us/sid#53e688][rid#56f7f0/initial] (2)
implicitly forcing redirect (rc=302) with http://mydomain.us/index.php/this/is/a/test/

Is there any way to avoid that implicit redirect in the above line?

    Thanks,
        Csaba Gabor from New York


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message