Click to See Complete Forum and Search --> : 301 Redirect - With Query String
OuterBox
05-05-2005, 07:28 PM
I am looking for a 301 redirect written in asp that will find query strings and then permanently redirect it to the new page with the new query string.
Example: http://www.smartestartist.com/scripts/prodList.asp?idCategory=6653
Would 301 to: http://www.smartestartist.com/prodList.asp?idCategory=1 (Page doesn't exist yet)
I'd be very grateful if someone could help me get this. This is the last step in getting my new site up!
Thanks a lot
phpnovice
05-05-2005, 07:44 PM
What is a 301 redirect?
OuterBox
05-05-2005, 07:51 PM
A permanent redirect. It's used for SEO purposes to show the search engine where you new pages are, instead of it finding a 404 and dropping that pages listing.
OuterBox
05-05-2005, 09:14 PM
No one? :/ Sorry for the rush....trying to get this up tonight
phpnovice
05-05-2005, 11:14 PM
You mean something like this?
If Request.QueryString("idCategory") = "6653" Then
Response.Redirect Request.ServerVariables("URL") & "?idCategory=1"
Response.End
End If
OuterBox
05-06-2005, 12:26 AM
Yep. I'll see if this works.
OuterBox
05-06-2005, 11:54 AM
Actually, it needs to be more like this, to be a 301 redirect (I must use a 301, permanent redirect).
This is close, but it still isn't working. It isn't giving me an error but it isn't forwarding to the right page either.
<%
q_string = Request.ServerVariables("idCategory")
if len(q_string)= 6653 then
Response.Status = "301 Moved Permanently"
Response.addheader "Location", "http://www.smartestartist.com/wholesaleart.asp"
Response.End
end if
%>
phpnovice
05-06-2005, 02:06 PM
This part can't be correct:
if len(q_string)= 6653 then
Shouldn't that be as follows?
if q_string = "6653" then
probably add the redirect after the addheader for some action.
phpnovice
05-12-2005, 09:17 AM
Actually, it needs to be more like this, to be a 301 redirect (I must use a 301, permanent redirect).
This is close, but it still isn't working. It isn't giving me an error but it isn't forwarding to the right page either.
What is the error? According to all the documentation, this should work:
<% @Language=VBScript %>
<%
If Request.QueryString("idCategory") = "6653" Then
Response.Buffer = True
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.smartestartist.com/wholesaleart.asp?idCategory=1"
Response.Flush
Response.End
End If
%>