ProductCart E-Commerce Solutions Homepage
Forum Home Forum Home > ProductCart > Customizing ProductCart
  New Posts New Posts RSS Feed - 301 Redirect
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

301 Redirect

 Post Reply Post Reply Page  12>
Author
Message
avalight View Drop Down
Newbie
Newbie


Joined: 21-September-2007
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote avalight Quote  Post ReplyReply Direct Link To This Post Topic: 301 Redirect
    Posted: 22-December-2009 at 11:12pm
What would be the best way to redirect this asp page:
http://www.avalanche-ranch.com/rusticlighting/pc/viewCategories.asp?idCategory=3

to this page

http://www.avalanche-ranch.com/rusticlighting/pc/viewCategories.asp?idCategory=4

I want to use a 301 redirect.  I have looked online for this.  I don't see a solution.  Perhaps the isapi rewrite?  Looks pretty complicated.  I have just stopped using that category...

Thanks
Curt
Avalanche Ranch Light Company

Edited by avalight - 22-December-2009 at 11:19pm
Curt
Back to Top
Greg Dinger View Drop Down
Certified ProductCart Developers
Certified ProductCart Developers
Avatar

Joined: 23-September-2006
Location: United States
Status: Offline
Points: 238
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greg Dinger Quote  Post ReplyReply Direct Link To This Post Posted: 22-December-2009 at 11:45pm
That's simple Curt.  Just place a bit of code in your header.asp
 
Here is the code that allows you to grab the current page name.
 
Here is the code for an ASP 301 redirect.
 
You need to wrap the 301 redirect with an IF statement that tests for which page you are on.  When you find that you are on the page you want to redirect from, pull the trigger and blast it.
Back to Top
worldofrugs View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24-April-2008
Location: United States
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldofrugs Quote  Post ReplyReply Direct Link To This Post Posted: 02-June-2010 at 3:26pm
Afraid it's not working for me :(

I tried adding this at the top of the  page:

Dim CatNumber
CatNumber= lcase(Request.ServerVariables("Query_String"))
if CatNumber="idcategory=224" then
Response.Status="301 Moved Permanently"
Response.Redirect "/shop/pc/TheOtherPage.asp"
Response.End()
else
if CatNumber="idcategory=11" then
Response.Status="301 Moved Permanently"
Response.Redirect "/shop/pc/OtherPage2.asp"
Response.End()
end if
end if


While the Re-Direct goes fine, the headr status is not returning 301, but 302!
Any suggestions?


Edited by worldofrugs - 02-June-2010 at 4:14pm
Back to Top
worldofrugs View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24-April-2008
Location: United States
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldofrugs Quote  Post ReplyReply Direct Link To This Post Posted: 02-June-2010 at 4:19pm
Never mind... Figured it out... Should have used:
Response.AddHeader "Location", "/shop/pc/OtherPage.asp" instead of the Respnse.Redirect

Time for more coffee!! Embarrassed
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 03-June-2010 at 1:20am
You might be able to find the category by simply doing:

<% if pIdCategory="number you want" then %>

Since viewcategories.asp is already populating that variable
Back to Top
worldofrugs View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24-April-2008
Location: United States
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldofrugs Quote  Post ReplyReply Direct Link To This Post Posted: 03-June-2010 at 9:50am
Thanks for that tip Brett!  Will try this out today and when it works (asuming it does), it will keep the coding a little cleaner
Thanks!
Clap
Back to Top
Greg Dinger View Drop Down
Certified ProductCart Developers
Certified ProductCart Developers
Avatar

Joined: 23-September-2006
Location: United States
Status: Offline
Points: 238
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greg Dinger Quote  Post ReplyReply Direct Link To This Post Posted: 03-June-2010 at 9:59am
Paul, on another note, you should make it a general practice to sanitize your reference to querystring values.  Whether the resulting value is sent to a query or not, use the "getuserinput" function.  Were you to not do so when sending a  querystring value to a query, you would create a security hold that could be deadly.
 
 
In your example above, the following statement would cause you massive grief "catnumber" was sent to a query and a hacker discovered it.
 
CatNumber= lcase(Request.ServerVariables("Query_String"))


Edited by Greg Dinger - 03-June-2010 at 9:59am
Back to Top
worldofrugs View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24-April-2008
Location: United States
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldofrugs Quote  Post ReplyReply Direct Link To This Post Posted: 03-June-2010 at 10:26am
Thanks for that tip Greg...
However, as I am not a programming guru, I'm not sure how to implement this in my situation.

I have quickly tried:
Dim idCategory
idCategory = getUserInput(Request("id"),5)
if idCategory="224" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/shop/pc/TheOtherPage.asp"
Response.End()
end if


but this does not work. It simply goes to the "msg.asp?message=86" page (not a valid category), not resulting in the redirect I want and not returning the 301 header status.

Did I miss something?
Back to Top
worldofrugs View Drop Down
Senior Member
Senior Member
Avatar

Joined: 24-April-2008
Location: United States
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote worldofrugs Quote  Post ReplyReply Direct Link To This Post Posted: 03-June-2010 at 10:30am
Never mind Greg, I found the issue.
On the Wiki page you gave me, you have the line:
Dim idCategory
idCategory = getUserInput(Request("id"),5)


But it should actually be:
Dim idCategory
idCategory = getUserInput(Request("idCategory "),5)


When I changed it this way, working great, so I assume that this is the best way to go?
Thanks for pointing it out Greg, 'you tha man'! Wink


Edited by worldofrugs - 03-June-2010 at 10:31am
Back to Top
Greg Dinger View Drop Down
Certified ProductCart Developers
Certified ProductCart Developers
Avatar

Joined: 23-September-2006
Location: United States
Status: Offline
Points: 238
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greg Dinger Quote  Post ReplyReply Direct Link To This Post Posted: 03-June-2010 at 10:33am
That's what I had in mind.  You DO NOT want to wake up one day and receive reports that the store has been attacked.  Concientious use of proper protection methods is absolutely critical.
Back to Top
 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.078 seconds.