Skip to content

Mod Rewrite - RewriteRule - redirections with absolute urls doesn't work #57693

Open
@arkadiuszwojcik

Description

@arkadiuszwojcik

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When creating mod_rewrite RewriteRule with redirection to different host/domain name (absolute url) it doesn't work properly because instead changing entire redirected url, destination is appended to requested url.

Expected Behavior

For redirections RewriteRule is internaly creating RedirectAction object that takes path base url always from: context.HttpContext.Request.PathBase but what if redirection destination is full url to other hostname/domain? In such case base url should be taken from destination and not like now from requested url.

When for example I have rule:
RewriteCond %{REQUEST_URI} ^./test/.$ [NC]
RewriteRule ^(.*)$ https://google.pl$1 [R=307,L]

When I enter: https://myhost.mydomain/test/abc I expect to be redirected to https://google.pl/test/abc but instead final url is: https://myhost.mydomainhttps://google.pl/test/abc

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

9.0.100-preview.7.24407.12

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions