Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
arkadiuszwojcik opened this issue Sep 4, 2024 · 0 comments
Open
1 task done
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware

Comments

@arkadiuszwojcik
Copy link

arkadiuszwojcik commented Sep 4, 2024

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware label Sep 4, 2024
@arkadiuszwojcik arkadiuszwojcik changed the title Mod Rewrite - RewriteRule - redirections with full host names doesn't work Mod Rewrite - RewriteRule - redirections with absolute urls doesn't work Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware
Projects
None yet
Development

No branches or pull requests

1 participant