You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ou...@centrum.cz on 2004/09/03 09:32:30 UTC

[users@httpd] mod_rewrite's behaviour changes while upgrading Apache1 -> 2

Hello,

I would like to upgrade Apache1 (13.29)  to Apache2 (2.0.50) but an exact behaviour of mod_rewrite have changed.

We're rewriting URL (hiding php page and variables)

How this zone is defined first:

<VirtualHost 1.2.3.4>
        ServerAdmin webmaster@domain.com
        ServerName www.domain.com
        ServerAlias domain.com *.domain.com
        RewriteEngine On
        RewriteCond  %{HTTP_HOST} !^www
        RewriteCond  %{HTTP_HOST} ^([^.]+)
        RewriteCond  %{DOCUMENT_ROOT}/%1 -d
        RewriteRule  ^/(.*) %{DOCUMENT_ROOT}/%1/$1
        RewriteCond  %{HTTP_HOST}  ^www\.ceadvisor\.cz
        RewriteRule  ^/page_(.*)_(.*)\.html$ http://www.domain.com/index.php?page=$1&service=$2 [L,QSA]
        DocumentRoot /domains/domain.com/
        ErrorLog logs/domain.com.error.log
        TransferLog logs/domain.com.transfer.log
        ErrorDocument   404     /404.php
</VirtualHost>

First set of Conds and the first rule should point subdomain into folders (easy and working)
The last Cond & Rule is the rule to hide php pages with 2 variables into a fake html page (to get better crawler positioning etc.)

Behaviour of Apache1:
Everything is fine and working, when I run www.domain.com/page_zviditelneni_1.html  -> the correct index.php?page=zviditelneni&service=1  is called and there's www.domain.com/page_zviditelneni_1.html in the URL line of my browser. That's how it should work

Behaviour of Apache2:
Unfortunately apache2 is doing it wrong. It calls good page, BUT send 302 REDIRECT code and redirect user to that php page. So, the problem is that user see index.php?page=zviditelneni&service=1 in his URL row instead of  www.domain.com/page_zviditelneni_1.html.

Check log for details :-/

62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (2) init rewrite eng
ine with requested uri /page_zviditelneni_1.html
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (3) applying pattern
 '^/(.*)' to uri '/page_zviditelneni_1.html'
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (4) RewriteCond: inp
ut='www.domain.com' pattern='!^www' => not-matched
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (3) applying pattern
 '^/page_(.*)_(.*)\.html$' to uri '/page_zviditelneni_1.html'
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (4) RewriteCond: inp
ut='www.domain.com' pattern='^www\.ceadvisor\.cz' => matched
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (2) rewrite /page_zv
iditelneni_1.html -> http://www.domain.com/index.php?page=zviditelneni&sluzba=1
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (3) split uri=http:/
/www.domain.com/index.php?page=zviditelneni&sluzba=1 -> uri=http://www.domain.com/index.php, args=page=zviditelnen
i&sluzba=1
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (2) implicitly forci
ng redirect (rc=302) with http://www.domain.com/index.php
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (1) escaping http://
www.domain.com/index.php for redirect
62.240.183.1 - - [29/Aug/2004:22:39:28 +0200] [www.domain.com/sid#81c9450][rid#84758c8/initial] (1) redirect to http
://www.domain.com/index.php?page=zviditelneni&sluzba=1 [REDIRECT/302]

Could anybody help please?

Best regards,

Roman






---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite's behaviour changes while upgrading Apache1 -> 2

Posted by Joshua Slive <js...@gmail.com>.
On Fri, 03 Sep 2004 09:32:30 +0200, outbound@centrum.cz
<ou...@centrum.cz> wrote:

>         RewriteRule  ^/page_(.*)_(.*)\.html$ http://www.domain.com/index.php?page=$1&service=$2 [L,QSA]

> Behaviour of Apache1:
> Everything is fine and working, when I run www.domain.com/page_zviditelneni_1.html  -> the correct index.php?page=zviditelneni&service=1  is called and there's www.domain.com/page_zviditelneni_1.html in the URL line of my browser. That's how it should work
> 
> Behaviour of Apache2:
> Unfortunately apache2 is doing it wrong. It calls good page, BUT send 302 REDIRECT code and redirect user to that php page. So, the problem is that user see index.php?page=zviditelneni&service=1 in his URL row instead of  www.domain.com/page_zviditelneni_1.html.

Hmmm... As far as I know, that is the way it always worked.  If not,
that is the way it was *supposed* to work.

In any case, the fix is easy, just change the absolute-url into a
url-path.  In other words, remove http://www.domain.com from the
front.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_rewrite's behaviour changes while upgrading Apache1 -> 2

Posted by Joe Orton <jo...@redhat.com>.
On Fri, Sep 03, 2004 at 09:32:30AM +0200, outbound@centrum.cz wrote:
...
>         RewriteCond  %{HTTP_HOST}  ^www\.ceadvisor\.cz
>         RewriteRule  ^/page_(.*)_(.*)\.html$ http://www.domain.com/index.php?page=$1&service=$2 [L,QSA]
...
> Behaviour of Apache2:
> Unfortunately apache2 is doing it wrong. It calls good page, BUT send 302 REDIRECT code and redirect user to that php page. So, the problem is that user see index.php?page=zviditelneni&service=1 in his URL row instead of  www.domain.com/page_zviditelneni_1.html.

If you get an implicit redirect from this rule that means the URI
reduction didn't happen, because the server thought that
"www.domain.com" didn't match the request, which may depend on the
UseCanonicalName setting and what URL you entered into the browser. 

If you omit the http://www.domain.com/ part from the right-hand-side of
the rule it should work correctly since you'll never get an implicit
redirect.

joe

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org