Clicky

I am changing a product configuration in an ASP based shopping cart from having many copies of the same product that each point to a different category to one in which one single product record will point to many categories.  I would like to use 301 redirects so that all of the old URLs that will be deleted/combined will now refer to the one remaining one.  Our hosting company is using IIS7.  Their instructions suggest putting the 301 redirects in the web.config file.  The problem is that there is going to be huge (60,000) number of these and I am concerned that this is going to cause problems.  Does anyone have ideas of how to handle this situation?

Thanks

asked 11/30/2011 04:26

ranger117's gravatar image

ranger117 ♦♦


8 Answers:
Yea, most hosting companies answer to everything is
Using the web.config file.

Now, since you are using IIS7, they SHOULD have a way for you to maintain and edit your 301 page, is so, that you can easily accomplish this, if you DO NOT have a way to edit it, then the only way to do it is like so.


If this is "Classic ASP" then you can have a header.asp page, and within that page.
You will do something like this.
And this will be added above your <html> tag, so that it gets called before the page starts to load.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
<%
scr = Request.ServerVariables("SCRIPT_NAME")&"?"&Request.ServerVariables("QUERY_STRING")
if instr(scr,"/")>0 then 
scr = right(scr, len(scr) - instrRev(scr,"/")) 
'response.Write scr
'response.End()
end if 
if scr = "Main.asp?pageid=1" then
Response.Status="301 Moved Permanently"
' the bottom 2 lines, allow you to post the header, and then a redirect to the new page.
Response.AddHeader "Location", "Main.asp?EVMID=1
response.Redirect"Main.asp?EVMID=1"
'---------------------------------
elseif scr = "Main.asp?pageid=2" then
Response.Status="301 Moved Permanently"
' the bottom 2 lines, allow you to post the header, and then a redirect to the new page.
Response.AddHeader "Location", "Main.asp?EVMID=2"
response.Redirect"Main.asp?EVMID=2"
end if
%>


If this is .net, then you will need to convert this over to that code.

I use the above code in our commercial sites, and it works beautifully.

Good Luck
Carrzkiss
link

answered

carrzkiss's gravatar image

carrzkiss

By the way.
If this is coming in from a database, and all the url's are similar to what I have above.
Basically.

?EVMID=1 ----> ?EVMID=60,000

Then you can just look at the QueryString, and then redirect as needed.
Without have to add in all these lines, as 60,000 will take forever.

Good Luck
Carrzkiss
link

answered 2011-11-30 at 13:19:59

carrzkiss's gravatar image

carrzkiss

Thanks very much for the response.  I believe that I can edit the 301 page.  If so, is there an easier way of doing this.  I actually have a text file that contains all of the old productids and the new.  The actual page would be www.xxx.com/prodpage.asp?id=1120997 and it would simply point to a new id.

Sorry if this is a dumb question, but I have never dealt with this before.

Thanks again
link

answered 2011-11-30 at 13:22:01

ranger117's gravatar image

ranger117

To do any rewrite you need to find patterns.

Can you give examples of what URL to want to rewrite too?

URL rewrite maps can be make life easier (1 --> 60001, 2--> 60002), etc

URLrewrite module is the way to go IMHO rather than change the 301 error page. What if there are other legitimate 301's it would try and redirect those.....

Either way you need a pattern of behaviour - if there is no pattern of behaviour - then you will have to do them all 60,000  by hand.

Personally I would question the need to do all this or at least the value to do it if too much needs changing.

Do you have *that* many hard links across the web to these old pages so they all need redirecting?  

What is the cost to losing these hard links to old pages ?

Compare this to the cost of creating anew system, testing it, and all these that re-directly wrongly, increased complexity/maintainable of the site.
link

answered 2011-11-30 at 13:58:51

Rovastar's gravatar image

Rovastar

I agree with Rovastar, that is only if you have access to a ReWrite module on the server side, if not, than doing a header redirect NOT the 301 page.
Would be the way to go.
link

answered 2011-11-30 at 15:35:40

carrzkiss's gravatar image

carrzkiss

Yes correct the module has to be installed. If the module is installed it is accessed by the web.config
link

answered 2011-11-30 at 15:45:45

Rovastar's gravatar image

Rovastar

Hi Guys,

My apologies for not getting back sooner.  As usual, I got dragged into another pressing problem...  I am going to use the code from the example Carrzkiss sent.  It looks like I can adapt it fairly easily and I can also use the table in our DB to check all the lookups.

Thanks
link

answered 2011-12-01 at 05:12:06

ranger117's gravatar image

ranger117

I have to adapt the code, but the example was very good.
link

answered 2011-12-14 at 11:00:48

ranger117's gravatar image

ranger117

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×1
×27
×8
×7

Asked: 11/30/2011 04:26

Seen: 290 times

Last updated: 12/14/2011 03:01