views:

24

answers:

3

Hello all,

One of my clients refers people to a certain URL. She prints the URL on physical letters, and the recipients have a few weeks to visit the URL and complete the task. Let's say that the URL she gives is:

www.department-a.domain.com/folder/important-page.html

The problem is that I am switching Content Management Systems so the page she links people to will sit at a different URL. But since she physically prints the URL on letters there needs to be some overlap so people can visit the old URL and be redirected.

Here's where it gets tricky. In the new system the subdomain of www.department-a.domain.com actually forwards to www.domain.com/index/department-a.aspx

Which isn't a folder but an actual page- which makes redirecting tricky. It also means I can't simply recreate the folder structure and use a simple HTML Meta refresh/redirect. Essentially my question is:

Is there anyway in IIS to tell the server that when someone attempts to view the specific and no longer existent URL of "www.department-a.domain.com/folder/important-page.html" to redirect them to another location? I'm new to .net and IIS so any input or links or tips are greatly appreciated.

Edit- Sorry, I'm using IIS7, not IIS6 like I previously indicated.

Thank you!

+1  A: 

Look into URL rewriting.

If using IIS 7: Here

bechbd
Hi bechbd. I will definitely look into the URL rewrite module. My question is- is it possible to redirect a single specific URL. I'm not very experienced with RegEx etc...
BlueDev
Yes it is possible to redirect a single URL using rewriting. Look a t using Rewrite Maps in URL rewriting: http://learn.iis.net/page.aspx/469/using-rewrite-maps-in-url-rewrite-module/
bechbd
A: 

I was new to .NET last month and needed this exact same solution. Everyone recommended URL rewriting plugins like bechbd mentioned, but I was just looking to forward a single URL. Surely there was a way? Turns out, there is not -- because IIS 6 is incredibly stupid.

Instead you will need to put code inside the actual page (or install the plugins if doing more than a couple URLs).

.ASP

<%@ Language=VBScript %>
<%
' Permanent redirection
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.example.com/"
Response.End
%>

.ASPX

<script language="VB" runat="server">
  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Response.Status = "301 Moved Permanently"
    Response.AppendHeader("Location", "http://www.example.com/")
  End Sub
</script>

I just implemented this code last month and all the search engines properly changed their index based on the 301s. I found a LOT of variations of this code around the web, but the code above worked great on my particular stock IIS 6.

degenerate
Hi Degenerate. Exactly, I don't need RegEx redirects for a whole collection of articles etc... just need a single URL. The hard part is- the URL the client is sending out has a subdomain at the beginning of it, which is setup to forward to a certain page, not directory. Which means I can't put code in the actual pages, since I cannot create the folder structure.
BlueDev
Then go ahead and install the IIS7 rewriting plugin. It was a major pain to install for IIS6 but looked pretty easy for 7, and should handle the subdomain problem you have.
degenerate
A: 

Url rewriting is the right way to fly. In a pinch, or stuck on IIS6, you can make a virtual directory anything at all. Including what seems to be a file name. And any virtual directory can be a server-side redirect.

To get around the department subdomain issue the key question is "is anything going to be running at those urls?" If not, then just setup a site to redirect the whole thing.

Wyatt Barnett