I want to redirect users from my dynamic URL to my static URL. The code I'm trying to use is the following: <% If Request.ServerVariables("url") = "/ProductDetails.asp" Then Response.Status="301 Moved Permanently" Response.AddHeader "Location", """/"" & replace(replace(replace(RS_Product.Fields(""ProductNameShort""), "" "", ""_""), ""."", ""_""), ""!"", """") & ""_p/"" & RS_Product.Fields(""ProductCode"") & "".htm""" End If %> But that code is pulling up this URL: /%22/%22%20&%20replace(replace(replace(RS_Product.Fields(%22ProductNameShort%22),%2 0%22%20%22,%20%22_%22),%20%22.%22,%20%22_%22),%20%22!%22,%20%22%22)%20&%20%22_ p/%22%20&%20RS_Product.Fields(%22ProductCode%22)%20&%20%22.htm%22) Is it possible to do what I'm attempting? If it is... what do I need to change in my current code to get this working? I should probably note... my dynamic URL would be something like: /ProductDetails.asp?ProductCode=pcode1 My static URL of that same page would be: /*ProductNameShort*_p/pcode1.htm My site takes the short product name, replaces spaces with underscores (along with other characters with blanks or underscores), and outputs like the URL shown above. I'm placing my redirect on my ProductDetails.asp. So when the page is called, it should be able to pull details from my database like ProductNameShort and pcode. For example... on my site... I'm using the following code to link to my static URL: <a href="<%=SEOImage("/" & replace(replace(replace(RS_Product.Fields("ProductNameShort"), " ", "_"), ".", "_"), "!", "") & "_p/" & RS_Product.Fields("ProductCode") & ".htm")%>"> That code works and shows a link to the correct static product page. But... I can't seem to modify the above code to get that working inside my 301 redirect. Any help would be appreciated.
I thought about doing something like this (it doesn't work... but it might be easier then what I was doing): <% Dim redirectURL redirectURL = SEOImage("/" & replace(replace(replace(RS_Product.Fields("ProductNameShort"), " ", "_"), ".", "_"), "!", "") & "_p/" & RS_Product.Fields("ProductCode") & ".htm") If Request.ServerVariables("url") = "/ProductDetails.asp" Then Response.Status="301 Moved Permanently" Response.AddHeader "Location", "redirectURL" End If %> I just need to find a way to make my redirectURL text located in Response.AddHeader actually call the variable I created. Not sure how to do that though