0

I am having an issue using IIS URl redirect module. Trying to redirect from www.site.com/directory1/default.aspx to www.site.com/directory2/default.aspx

So any request to directory1 needs to go to directory 2. I am going to be disabling the application at directory 1 Any ideas? Currently i have the below, but does not work.

<rewrite>
            <rules>
                <remove name="Portal Test Redirect" />
                <rule name="Portal Test Redirect" patternSyntax="Wildcard">
                    <match url="*directory1/*" ignoreCase="false" />
                    <conditions />
                    <serverVariables />
                    <action type="Rewrite" url="{R:1}/directory2/{R:2}" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>        

2 Answers 2

1

You need to change your rule as below

<rewrite>
    <rules>            
        <rule name="Portal Test Redirect">
            <match url="(.*)(directory1)(.*)" patternSyntax="ECMAScript"/>
            <action type="Rewrite" url="{R:1}directory2{R:3}" />
        </rule>
    </rules>
</rewrite>
Sign up to request clarification or add additional context in comments.

5 Comments

Would this deal with query string parameters as well? All i need is the directory to change
Yes it should be but I haven't tested it.
Are you still running into issues?
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
That's nothing to do with URL Rewrite rule. Looks like you are adding a section in child web.config which is not allowed there. Can you confirm where are you adding the rule and which section you are getting this error for ?
0

1.Open web.config in the directory where the old pages reside 2.Then add code for the old location path and new destination as follows:

<configuration>
  <location path="services.htm">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://domain.com/services" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
  <location path="products.htm">
    <system.webServer>
      <httpRedirect enabled="true" destination="http://domain.com/products" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>

Try above. Refered from Setting up redirect in web.config file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.