OK i have a site that i am moving... Old URLs are: www.domain.com/category.asp?category_id=1 www.domain.com/category.asp?category_id=2 www.domain.com/category.asp?category_id=3 new URLs are www.newdomain.com/shop/item1 www.newdomain.com/shop/item2 www.newdomain.com/shop/item3 So i need to write something in asp that will that will 301 redirect if url = "?category_id=1" redirect to www.newdomain.com/shop/item1 if url = "?category_id=2" redirect to www.newdomain.com/shop/item2 if url = "?category_id=3" redirect to www.newdomain.com/shop/item3 else redirect to www.newdomain.com/index.asp Just so you understand google has indexed all 3 of these examples: www.domain.com/category.asp?category_id=1 www.domain.com/category.asp?category_id=2 www.domain.com/category.asp?category_id=3 So, I want a different 301 redirect TO 3 different pages, but the code needs to be embedded on one page: if url = "?category_id=1" redirect to www.newdomain.com/shop/item1 if url = "?category_id=2" redirect to www.newdomain.com/shop/item2 if url = "?category_id=3" redirect to www.newdomain.com/shop/item3 else redirect to www.newdomain.com/index.asp I have googled this with no luck. Thanks for any help
Something like: <% Dim catId catId = Request.QueryString("category_id") If catId >= 1 And catId <= 3 Then Response.Redirect "http://www.newdomain.com/shop/item" & catId Else Response.Redirect "http://www.newdomain.com/index.asp" End If %> Code (markup): that would be saved to domain.com/category.asp
This is what I ended up writing. Not sure if it was the best way, but it worked. Thanks again for your help, input. <%@ Language=VBScript %> <% DIM strcategory_id strcategory_id = Request.QueryString("category_id") IF strcategory_id = "32" THEN Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://domain.com/shop/Stickers_and_Labels" ELSEIF strcategory_id = "21" THEN Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://domain.com/shop/CD_and_DVD" ELSE Response.Status="301 Moved Permanently" Response.AddHeader "Location","http://domain.com" END IF Code (markup):