I would like to setup a redirect where if a visitor with a certain IP address ends up landing on a specific page, I'd like to redirect them to another page. For example, visitors with IP address of 12.4.0.1 or 165.89.0,1 land on index1.htm, instantly redirect
those those visitors to index2.htm. Is there any way to do this with ASP, Javascript or change a setting in IIS Manager? Just a note, I'm not a developer or web guru so the easiest solution would be very heflpful :) Thanks
I can bo done with asp.net page. You can write a simple code on onpageload event and check the ip of the user and then manipulate it according to your wish. Check out the example below for aspx page
Hi developer123, thank you, but it didnt seem to work. I dont know ASP very well, is there suppose to be a start and end tag to this script? Also, where do I insert the script? In the Header? Thanks!
serena46
0 Points
2 Posts
ASP redirect based on IP address
Oct 14, 2010 02:41 PM|LINK
I would like to setup a redirect where if a visitor with a certain IP address ends up landing on a specific page, I'd like to redirect them to another page. For example, visitors with IP address of 12.4.0.1 or 165.89.0,1 land on index1.htm, instantly redirect those those visitors to index2.htm. Is there any way to do this with ASP, Javascript or change a setting in IIS Manager? Just a note, I'm not a developer or web guru so the easiest solution would be very heflpful :) Thanks
redirect 301 redirect
developer123
Member
301 Points
91 Posts
Re: ASP redirect based on IP address
Oct 14, 2010 07:31 PM|LINK
I can bo done with asp.net page. You can write a simple code on onpageload event and check the ip of the user and then manipulate it according to your wish. Check out the example below for aspx page
protected void Page_Load(object sender, EventArgs e) { string ip = Request.UserHostAddress; if(ip=="127.0.0.1") { response.redirect("abc.htm"); } }The above written code might help you.
ip Address
Anurag Mehra
"The similarity between god and human is that they both created each other."
"Mark As An Answer" if it helps
serena46
0 Points
2 Posts
Re: ASP redirect based on IP address
Oct 14, 2010 07:51 PM|LINK
Hi developer123, thank you, but it didnt seem to work. I dont know ASP very well, is there suppose to be a start and end tag to this script? Also, where do I insert the script? In the Header? Thanks!
developer123
Member
301 Points
91 Posts
Re: ASP redirect based on IP address
Oct 15, 2010 06:46 AM|LINK
working with ASP is different as compared to working with asp.net. I know a little about asp.net but have no idea about asp.
If you are using asp.net then this code should be written in aspx.cs page i.e. the code behind page
Anurag Mehra
"The similarity between god and human is that they both created each other."
"Mark As An Answer" if it helps
Yanping Wang...
Star
14871 Points
1529 Posts
Microsoft
Re: ASP redirect based on IP address
Oct 20, 2010 06:37 AM|LINK
hi developer123,
for asp, please use Request.ServerVariables("REMOTE_ADDR") get visitor's IP address
<%
dim ip
ip = Request.ServerVariables("REMOTE_ADDR")
if (ip="127.0.0.1") then
Response.Redirect("abc.htm")
end if
%>
Feedback to us
Develop and promote your apps in Windows Store
developer123
Member
301 Points
91 Posts
Re: ASP redirect based on IP address
Oct 20, 2010 06:23 PM|LINK
Thanks.
Anurag Mehra
"The similarity between god and human is that they both created each other."
"Mark As An Answer" if it helps