UnrealMan
UnrealMan

Reputation: 5

IIS 8.5 URL rewrite with Regex doesn't work

I want to rewrite all user URL requests from

_http://localhost:5678/dir/index.html

to

_http://localhost:5678/subdir/dir/index.html

In my ISS URL rewrite module rules I use this pattern: ^(https?://[^/][:0-9]/)(.*)$

using this pattern URL address divided into two parts: host-name and directory with page or any other content. In IIS action properties Redirect URL field I write: {R:1}subdir/{R:2}

I think that this rule should redirect all requests from

_http://host-name/page.html

to

_http://host-name/subdir/page.html

but this is not work. Changing Action type from Rewrite to Redirect doesn't work to. When in Redirect URL field I write direct URL to resources (for example, _http://localhost:5678/subdir/dir/index.html) IIS trying to redirect me to that URL but browser (Firefox and Chrome) throw an exception ERR_TOO_MANY_REDIRECTS. How I can to configure IIS URL rewrite action properly?

Upvotes: 0

Views: 575

Answers (1)

zman
zman

Reputation: 189

Use this pattern instead since you don't have to match the entire pattern to accomplish this. ^(/dir)(/.*)?

then the redirect URL should look like

{HTTP_HOST}/subdir/{R:1}{R:2}

Upvotes: 0

Related Questions