...

View Full Version : Dynamic 301 redirect based on url.



rumblepup
02-06-2007, 03:13 PM
Hello all. I've been trying to figure out a redirect system for a site that I'm updating from classic asp to asp.net.

Currently, the site has some product search and product detail pages such as:
prodList.asp?idCategory=9
or
prodView.asp?idproduct=55

Well, what I want to do is create a 301 redirect from those pages to the new one, based on the idCategory parameter or the idproduct parameter.

I found neat little 301 redirect code

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", " http://www.new-url.com"
>

But I want to create a series of IF/Then statements that will redirect based on the uri parameter, and I'm not sure how to do it.

In other words, my logic is -

If WEBSITE uri = ../prodView.asp?idproduct=55
THEN
Response.Status="301 Moved Permanently" Response.AddHeader "Location", "new-url(dot)com"

I have to do this one line at a time because the Product ID's and the Category ID's will change with the new asp.net application.

In any case, any ideas? I've never written code from scratch, that's why I stink at this.

Thanks ahead of time.

degsy
02-13-2007, 03:02 PM
You don't know how to do If/Else validation?
See here (Assuming you are using ASP VBScript)
http://www.w3schools.com/vbscript/vbscript_conditionals.asp



A better way would be to use URL Rewriting/Redirecting.

You can install components such as ISAPIRewrite and use a regular expression to redirect your URLs.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum