Link to home
Start Free TrialLog in
Avatar of SWB-Consulting
SWB-Consulting

asked on

index.asp redirect generates infinite loop

- we have a website hosted with verio: www.clickinsure.com
- when I go to http://www.clickinsure.com/index.asp we would like it to take the user to www.clickinsure.com via a 301 redirect
- we pasted asp redirect code at the top of the index.asp file but this generated an infinite loop

how can we accomplish our objective?
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

here you go.
Tested and works
(Put it at the top of the page)
Carrzkiss
<%if Request.ServerVariables("URL")="/index.asp" then%>
<%response.Redirect"http://www.clickinsure.com"%>
<%end if%>

Open in new window

Avatar of SWB-Consulting
SWB-Consulting

ASKER

checking now.
when i try this i get the following error:

Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.
    * Have you disabled or blocked cookies required by this site?
    * NOTE: If accepting the site's cookies does not resolve the problem, it is likely a server configuration issue and not your computer.
I just tested it in FF and it went well.
I do not get the error that you are describing here.
It redirects to the page that I specified, which in this case, is this page.

This is the actual Code that I am using.
As you can see it has a longer path to look at.
This is the actual server path

<%if Request.ServerVariables("URL")="/ee/Q_24477649/Q_24477649.asp" then%>
<%response.Redirect"https://www.experts-exchange.com/questions/24477649/index-asp-redirect-generates-infinite-loop.html?cid=295"%>
<%end if%>

Test it out here. Using both Firefox and IE
http://ee.cffcs.com/Q_24477649/Q_24477649.asp

Carrzkiss
ok, what do i need to do to make it work on http://www.clickinsure.com/index.asp ?
Run this on your page and paste the results in here please


<%=Request.ServerVariables("URL")%>
this is what it returns when i go to http://www.clickinsure.com/ OR http://www.clickinsure.com/index.asp :

/index.asp
then this should work then

<%if Request.ServerVariables("URL")="/index.asp" then%>
<%response.Redirect"http://www.clickinsure.com"%>
<%end if%>

with running this url:         http://www.clickinsure.com/index.asp


The function <%=Request.ServerVariables("URL")%> returns /index.asp as a result even when I only browse to www.clickinsure.com so naturally it generates a redirect loop because the check always returns a true.
you know, your right.
The only way to get around this, is to change the default file type from
index.asp
to
default.asp

But, if you deal with a Hosting provider, this might be difficult to accomplish.
But, if you host inhouse, then just go into IIS and change the Default file type
For the domain to default.asp
And remove the index.asp
The only thing that you would have to do from there would be to duplicate your index.asp
Page and name it: default.asp

I know that is a lot to do, but I think this is going to be your only alternative.
Unless someone comes in that knows of another way.

And then when you run the code that I supplied, the main domain url will pick up on the default.asp
And not the index.asp, and their will no longer be an infinite loop.

Hope that makes since.
Just something that I thought of at the moment, that might help to resolve the issue of the loop.

Carrzkiss
that worked. it now redirects from clickinsure.com/index.asp to clickinsure.com, but it is a 302 redirect. would it be possible to make it a 301 redirect?
actually i would like to know what i need to change in your redirect code in order to turn it into a 301
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SWB
How is this going?
If it is working, then please accept an answer so we can finalize this one.
If it is nothing working, then let me know so we can get this one taken care of.

Carrzkiss
>>actually i would like to know what i need to change in your redirect code in order to turn it into a 301

I gave you what you asked for, and you gave me a Grade of [B]
That is totally wrong SWB.
If you did not want it, then you should have not asked for it.
Totally wrong.

Carrzkiss