httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Csaba Gabor <>
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
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 Gabor <> wrote:
Here I am with Apache 2, PHP 4.2, Windows 2K, and a problem.  I have a site with main page 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 I can write something like

So I appeal to the handy, dandy ModRewrite and come up with something like (perhaps I could
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 ^(.*)$$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
changed (same change happens even if prefixed with http://) from
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: - - [23/Jun/2002:22:55:34 --0500] [][rid#56f7f0/initial] (3)
applying pattern '^(.*)$' to uri '/this/is/a/test/' - - [23/Jun/2002:22:55:34 --0500] [][rid#56f7f0/initial] (2)
rewrite /this/is/a/test/ -> - - [23/Jun/2002:22:55:34 --0500] [][rid#56f7f0/initial] (2)
implicitly forcing redirect (rc=302) with

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

        Csaba Gabor from New York

Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message