Web Connection
Familiar with URL Rewrite 2 (IIS 7.5)? - advice?
Gravatar is a globally recognized avatar based on your email address. Familiar with URL Rewrite 2 (IIS 7.5)? - advice?
  n/a
  All
  Apr 11, 2014 @ 02:28pm
Is anybody familiar with URL Rewrite 2 for IIS 7.5?

I'm trying to do some 301 redirects and not having much luck. It was pretty easy to do in IIS 6 with static redirects.

I have a bunch of things going on all at once (for various reasons, just made sense to do them all at once, even if a bit harder that way).

The first thing is upgrading to a new Win 2008 R2 / IIS 7.5 server, from our old Win 2003/IIS 6.
(They are 2 separate server boxes so we could run parallel for testing)

Then there is a company name / domain change.
www.oldcompanyname.com -> www.newcompanyname.com

But then there are also some page changes, so it is not a 1 to 1 correlation, for example:
(I upgraded Web Connection and used script map for wc.dll), so
www.oldcompanyname.com/services/wc.dll?myprg~myfunction
needs to point to
www.newcompanyname.com/services/wc.wc?myprg~myfunction

I don't see an easy way to do this with the traditional "HTTP Redirect" icon in IIS 7.5.
So I installed URL Rewrite 2, and have been trying to use examples I found
to have my rewrite maps in file called rewritemap.config that is separate from the web.config.
That way, it is just easier to maintain and also won't get accidentally overwritten.
(I've got hundreds of 301 redirects to do in addition to my web connection one.)
The rewritemap.config and web.config are both in the root directory
associated with www.oldcompanyname.com.

Anyway, when I try to implement the solution, I get a 500 - Internal server error (there is a problem with the resource you are looking for, and it cannot be displayed).

But I can't figure out what I am doing wrong. I don't know if the problem is the code in my web.config, code in my rewritemap.config, that it can't find the rewritemap.config, or that the redirect is failing.

Here is an example of my code:
In web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemap.config" />
<rules>
<rule name=”Redirect rule1 for Redirects” stopProcessing="true">
<match url=”.*” />
<conditions>
<add input=”{Redirects:{REQUEST_URI}}” pattern=”(.+)” />
</conditions>
<action type=”Redirect” url=”{C:1}” appendQueryString=”false” redirectType="Permanent" />
</rule>
</rules>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Then in my rewritemap.config

<rewriteMaps>
<rewriteMap name=”Redirects”>
<add key=”/index.htm” value=”http://www.newcompanyname.com/index.htm” />
</rewriteMap>
</rewriteMaps>

Would love suggestions of things to try, or if somebody can see what I'm missing - even better! =)

Gravatar is a globally recognized avatar based on your email address. Re: Familiar with URL Rewrite 2 (IIS 7.5)? - advice?
  Rick Strahl
  Shelly Rexroat
  Apr 11, 2014 @ 02:40pm
Are you sure the rewrite module is installed? Use the Web Platform installer (in IIS or from the start menu) to check.

+++ Rick ---



Is anybody familiar with URL Rewrite 2 for IIS 7.5?

I'm trying to do some 301 redirects and not having much luck. It was pretty easy to do in IIS 6 with static redirects.

I have a bunch of things going on all at once (for various reasons, just made sense to do them all at once, even if a bit harder that way).

The first thing is upgrading to a new Win 2008 R2 / IIS 7.5 server, from our old Win 2003/IIS 6.
(They are 2 separate server boxes so we could run parallel for testing)

Then there is a company name / domain change.
www.oldcompanyname.com -> www.newcompanyname.com

But then there are also some page changes, so it is not a 1 to 1 correlation, for example:
(I upgraded Web Connection and used script map for wc.dll), so
www.oldcompanyname.com/services/wc.dll?myprg~myfunction
needs to point to
www.newcompanyname.com/services/wc.wc?myprg~myfunction

I don't see an easy way to do this with the traditional "HTTP Redirect" icon in IIS 7.5.
So I installed URL Rewrite 2, and have been trying to use examples I found
to have my rewrite maps in file called rewritemap.config that is separate from the web.config.
That way, it is just easier to maintain and also won't get accidentally overwritten.
(I've got hundreds of 301 redirects to do in addition to my web connection one.)
The rewritemap.config and web.config are both in the root directory
associated with www.oldcompanyname.com.

Anyway, when I try to implement the solution, I get a 500 - Internal server error (there is a problem with the resource you are looking for, and it cannot be displayed).

But I can't figure out what I am doing wrong. I don't know if the problem is the code in my web.config, code in my rewritemap.config, that it can't find the rewritemap.config, or that the redirect is failing.

Here is an example of my code:
In web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemap.config" />
<rules>
<rule name=”Redirect rule1 for Redirects” stopProcessing="true">
<match url=”.*” />
<conditions>
<add input=”{Redirects:{REQUEST_URI}}” pattern=”(.+)” />
</conditions>
<action type=”Redirect” url=”{C:1}” appendQueryString=”false” redirectType="Permanent" />
</rule>
</rules>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Then in my rewritemap.config

<rewriteMaps>
<rewriteMap name=”Redirects”>
<add key=”/index.htm” value=”http://www.newcompanyname.com/index.htm” />
</rewriteMap>
</rewriteMaps>

Would love suggestions of things to try, or if somebody can see what I'm missing - even better! =)



Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: Familiar with URL Rewrite 2 (IIS 7.5)? - advice?
  n/a
  Rick Strahl
  Apr 11, 2014 @ 03:04pm
Actually before working on the 301 redirects, I had created a rule on the new website for redirecting http to https for certain directories using the URL Rewrite. And that seems to be working fine. So I can tell that URL Rewrite 2 is installed.

But that does give me an idea. Maybe I can just create a little rule on the old website, that redirects to another page on the old website. That should tell me if it is this code or that it is not working at all on the old site.

I'll try that and see how it goes...

Thanks,
Shelly



Are you sure the rewrite module is installed? Use the Web Platform installer (in IIS or from the start menu) to check.

+++ Rick ---



Is anybody familiar with URL Rewrite 2 for IIS 7.5?

I'm trying to do some 301 redirects and not having much luck. It was pretty easy to do in IIS 6 with static redirects.

I have a bunch of things going on all at once (for various reasons, just made sense to do them all at once, even if a bit harder that way).

The first thing is upgrading to a new Win 2008 R2 / IIS 7.5 server, from our old Win 2003/IIS 6.
(They are 2 separate server boxes so we could run parallel for testing)

Then there is a company name / domain change.
www.oldcompanyname.com -> www.newcompanyname.com

But then there are also some page changes, so it is not a 1 to 1 correlation, for example:
(I upgraded Web Connection and used script map for wc.dll), so
www.oldcompanyname.com/services/wc.dll?myprg~myfunction
needs to point to
www.newcompanyname.com/services/wc.wc?myprg~myfunction

I don't see an easy way to do this with the traditional "HTTP Redirect" icon in IIS 7.5.
So I installed URL Rewrite 2, and have been trying to use examples I found
to have my rewrite maps in file called rewritemap.config that is separate from the web.config.
That way, it is just easier to maintain and also won't get accidentally overwritten.
(I've got hundreds of 301 redirects to do in addition to my web connection one.)
The rewritemap.config and web.config are both in the root directory
associated with www.oldcompanyname.com.

Anyway, when I try to implement the solution, I get a 500 - Internal server error (there is a problem with the resource you are looking for, and it cannot be displayed).

But I can't figure out what I am doing wrong. I don't know if the problem is the code in my web.config, code in my rewritemap.config, that it can't find the rewritemap.config, or that the redirect is failing.

Here is an example of my code:
In web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemap.config" />
<rules>
<rule name=”Redirect rule1 for Redirects” stopProcessing="true">
<match url=”.*” />
<conditions>
<add input=”{Redirects:{REQUEST_URI}}” pattern=”(.+)” />
</conditions>
<action type=”Redirect” url=”{C:1}” appendQueryString=”false” redirectType="Permanent" />
</rule>
</rules>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Then in my rewritemap.config

<rewriteMaps>
<rewriteMap name=”Redirects”>
<add key=”/index.htm” value=”http://www.newcompanyname.com/index.htm” />
</rewriteMap>
</rewriteMaps>

Would love suggestions of things to try, or if somebody can see what I'm missing - even better! =)



Gravatar is a globally recognized avatar based on your email address. Re: Familiar with URL Rewrite 2 (IIS 7.5)? - advice?
  n/a
  Shelly Rexroat
  Apr 11, 2014 @ 03:24pm
Well - I was able to use the URL Rewrite in the IIS GUI to create a rule for all lowercase, and that works fine on the old site.

Looks like there is something wrong with the <rewriteMaps... statement in the web.config.

Think I'll work on it more on Monday. Maybe a fresh mind will help me figure out the correct syntax for that.

Thanks,
Shelly


Actually before working on the 301 redirects, I had created a rule on the new website for redirecting http to https for certain directories using the URL Rewrite. And that seems to be working fine. So I can tell that URL Rewrite 2 is installed.

But that does give me an idea. Maybe I can just create a little rule on the old website, that redirects to another page on the old website. That should tell me if it is this code or that it is not working at all on the old site.

I'll try that and see how it goes...

Thanks,
Shelly



Are you sure the rewrite module is installed? Use the Web Platform installer (in IIS or from the start menu) to check.

+++ Rick ---



Is anybody familiar with URL Rewrite 2 for IIS 7.5?

I'm trying to do some 301 redirects and not having much luck. It was pretty easy to do in IIS 6 with static redirects.

I have a bunch of things going on all at once (for various reasons, just made sense to do them all at once, even if a bit harder that way).

The first thing is upgrading to a new Win 2008 R2 / IIS 7.5 server, from our old Win 2003/IIS 6.
(They are 2 separate server boxes so we could run parallel for testing)

Then there is a company name / domain change.
www.oldcompanyname.com -> www.newcompanyname.com

But then there are also some page changes, so it is not a 1 to 1 correlation, for example:
(I upgraded Web Connection and used script map for wc.dll), so
www.oldcompanyname.com/services/wc.dll?myprg~myfunction
needs to point to
www.newcompanyname.com/services/wc.wc?myprg~myfunction

I don't see an easy way to do this with the traditional "HTTP Redirect" icon in IIS 7.5.
So I installed URL Rewrite 2, and have been trying to use examples I found
to have my rewrite maps in file called rewritemap.config that is separate from the web.config.
That way, it is just easier to maintain and also won't get accidentally overwritten.
(I've got hundreds of 301 redirects to do in addition to my web connection one.)
The rewritemap.config and web.config are both in the root directory
associated with www.oldcompanyname.com.

Anyway, when I try to implement the solution, I get a 500 - Internal server error (there is a problem with the resource you are looking for, and it cannot be displayed).

But I can't figure out what I am doing wrong. I don't know if the problem is the code in my web.config, code in my rewritemap.config, that it can't find the rewritemap.config, or that the redirect is failing.

Here is an example of my code:
In web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemap.config" />
<rules>
<rule name=”Redirect rule1 for Redirects” stopProcessing="true">
<match url=”.*” />
<conditions>
<add input=”{Redirects:{REQUEST_URI}}” pattern=”(.+)” />
</conditions>
<action type=”Redirect” url=”{C:1}” appendQueryString=”false” redirectType="Permanent" />
</rule>
</rules>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Then in my rewritemap.config

<rewriteMaps>
<rewriteMap name=”Redirects”>
<add key=”/index.htm” value=”http://www.newcompanyname.com/index.htm” />
</rewriteMap>
</rewriteMaps>

Would love suggestions of things to try, or if somebody can see what I'm missing - even better! =)




Gravatar is a globally recognized avatar based on your email address. Re: Familiar with URL Rewrite 2 (IIS 7.5)? - advice?
  n/a
  Shelly Rexroat
  Apr 14, 2014 @ 12:03pm
Just wanted to post how I got it to work.
I found out how to do a rewritemap using the IIS 7.5 GUI interface. I'll also post a sample of what the web.config looks like afterward (even though I'll probably maintain the map in IIS interactively)

Open IIS 7.5
Navigate to the "old" website you want to redirect to new pages
Double-click the "URL Rewrite" icon
In the action pane, click "View Rewrite Maps..."
Click "Add Rewrite Map..." in the action pane
Enter a name that makes sense to you and click OK
Click "Add Mapping Entry..."
Enter the old URL (using relative path) as the "original value" and the new URL (which can include a new domain name - i.e. www.newsite.com/...) (or relative path of old site) as the "New Value" and click OK
(Repeat as needed to add all your redirects)
Then click "Back to Rules" in the action pane
Now you are going to apply the rewrite map as a rule, so click "Add Rule(s)" from the action pane.
In the "Inbound Rules" section, choose the "Rule with rewrite map" and click OK.
Then in my case, I'm wanting to do 301 redirects, so I choose "Redirect" in the top drop-down.
In the "Select the rewrite map:" choose the name you gave your map in the steps above from the drop-down.
Then click OK.
Voila - the redirects work!

To maintain the redirects later - open iis, navigate to old site, double-click URL Rewrite, click View Rewrite Maps, and double-click the rewrite map name. From there you can Add, Edit, or Remove mapping entries.

Here is an example web.config after doing a rewrite map this way. (Note that the rules are all in the web.config itself and not a separate file. In the future, I may break them out into a separate file if the web.config gets too big. But for now, I don't care that it is all in the same config.)

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rule1 for oldsite_newsite">
<match url=".*" />
<conditions>
<add input="{oldsite_newsite:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="oldsite_newsite">
<add key="/suggestions.htm" value="http://www.newsite.com/suggestions.htm" />
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>


Well - I was able to use the URL Rewrite in the IIS GUI to create a rule for all lowercase, and that works fine on the old site.

Looks like there is something wrong with the <rewriteMaps... statement in the web.config.

Think I'll work on it more on Monday. Maybe a fresh mind will help me figure out the correct syntax for that.

Thanks,
Shelly


Actually before working on the 301 redirects, I had created a rule on the new website for redirecting http to https for certain directories using the URL Rewrite. And that seems to be working fine. So I can tell that URL Rewrite 2 is installed.

But that does give me an idea. Maybe I can just create a little rule on the old website, that redirects to another page on the old website. That should tell me if it is this code or that it is not working at all on the old site.

I'll try that and see how it goes...

Thanks,
Shelly



Are you sure the rewrite module is installed? Use the Web Platform installer (in IIS or from the start menu) to check.

+++ Rick ---



Is anybody familiar with URL Rewrite 2 for IIS 7.5?

I'm trying to do some 301 redirects and not having much luck. It was pretty easy to do in IIS 6 with static redirects.

I have a bunch of things going on all at once (for various reasons, just made sense to do them all at once, even if a bit harder that way).

The first thing is upgrading to a new Win 2008 R2 / IIS 7.5 server, from our old Win 2003/IIS 6.
(They are 2 separate server boxes so we could run parallel for testing)

Then there is a company name / domain change.
www.oldcompanyname.com -> www.newcompanyname.com

But then there are also some page changes, so it is not a 1 to 1 correlation, for example:
(I upgraded Web Connection and used script map for wc.dll), so
www.oldcompanyname.com/services/wc.dll?myprg~myfunction
needs to point to
www.newcompanyname.com/services/wc.wc?myprg~myfunction

I don't see an easy way to do this with the traditional "HTTP Redirect" icon in IIS 7.5.
So I installed URL Rewrite 2, and have been trying to use examples I found
to have my rewrite maps in file called rewritemap.config that is separate from the web.config.
That way, it is just easier to maintain and also won't get accidentally overwritten.
(I've got hundreds of 301 redirects to do in addition to my web connection one.)
The rewritemap.config and web.config are both in the root directory
associated with www.oldcompanyname.com.

Anyway, when I try to implement the solution, I get a 500 - Internal server error (there is a problem with the resource you are looking for, and it cannot be displayed).

But I can't figure out what I am doing wrong. I don't know if the problem is the code in my web.config, code in my rewritemap.config, that it can't find the rewritemap.config, or that the redirect is failing.

Here is an example of my code:
In web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps configSource="rewritemap.config" />
<rules>
<rule name=”Redirect rule1 for Redirects” stopProcessing="true">
<match url=”.*” />
<conditions>
<add input=”{Redirects:{REQUEST_URI}}” pattern=”(.+)” />
</conditions>
<action type=”Redirect” url=”{C:1}” appendQueryString=”false” redirectType="Permanent" />
</rule>
</rules>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Then in my rewritemap.config

<rewriteMaps>
<rewriteMap name=”Redirects”>
<add key=”/index.htm” value=”http://www.newcompanyname.com/index.htm” />
</rewriteMap>
</rewriteMaps>

Would love suggestions of things to try, or if somebody can see what I'm missing - even better! =)





© 1996-2024