[Bug 63497] New: Backreferences have different values depending on use

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 63497] New: Backreferences have different values depending on use

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63497

            Bug ID: 63497
           Summary: Backreferences have different values depending on use
           Product: Apache httpd-2
           Version: 2.4.25
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

I have a this setup in my .htaccess file:

RewriteRule ^wohnmobil-kaufen/([a-z0-9\-]+)-(?:[a-z0-9]+)/([a-z0-9\-]+)\.html$
/wohnmobil-kaufen/$1/$2.html [R=302,NC]

When I call the site with the following url path:

/wohnmobil-kaufen/la-strada-wohnmobile/la-strada-avanti-l.html

I would expect to be redirected to

/wohnmobil-kaufen/la-strada/la-strada-avanti-l.html

But I get redirected to:

/wohnmobil-kaufen/la/la-strada-avanti-l.html

As you can see, $1 and the not capturing group are not working correctly.
If I check my regex in regex101, it works as expected.

Now comes the really strange part:

If I change my Rule to this

RewriteRule ^wohnmobil-kaufen/([a-z0-9\-]+)-(?:[a-z0-9]+)/([a-z0-9\-]+)\.html$
/wohnmobil-kaufen/$1/$3.html [R=302,NC]

As you can see, I am using a non existent $3 variable.

Then by calling the same url path I am redirected to:

/wohnmobil-kaufen/la-strada/.html

The part between / and . is empty because $3 does not exist, but the first part
is correct. So By using an invalid unrelated variable I have a different value
in my captured group.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63497] Backreferences have different values depending on use

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63497

--- Comment #1 from ducklife <[hidden email]> ---
Sharing is very useful. You are a great author. I will definitely bookmark your
blog and maybe come back someday Thanks for a great article. Please continue to
uphold!
  https://templerun.co

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 63497] Backreferences have different values depending on use

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=63497

Mariano Custiel <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Mariano Custiel <[hidden email]> ---
I will close it because it's not a bug. The problem is that the pattern is
catched again after the first redirect, so 2 redirections are happening.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]