Forum Moderators: open
<%
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),%20%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?
/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.
<%
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 :)