Forum Moderators: open
I am currently struggling with a situation where I have two pages in google (where only one should exist).
These pages are www.example.com and www.example.com/default.aspx
I want to be able to redirect from the www.example.com/default.aspx one to www.example.com if I find it in the URL.
I have been playing around with getting headers and Server variables and seeing if any of them contain "default.aspx" but because default.aspx is the default page I cant find one that gives me the exact URL in the Address bar.
Any one tried someting like this before?
here are all the vars that might have been useful and their values, am I missing anything?
Is there perhaps someting else that I havent tried?
www.example.com
PATH_INFO : /Default.aspx
PATH_TRANSLATED : C:\somefolder\Default.aspx
SCRIPT_NAME : /Default.aspx
URL : /Default.aspx
HTTP_HOST : www.example.com
www.example.com/Default.aspx
PATH_INFO : /Default.aspx
PATH_TRANSLATED : C:\somefolder\Default.aspx
SCRIPT_NAME : /Default.aspx
URL : /Default.aspx
HTTP_HOST : www.example.com
As you can see both give exactly the same results.
Here is the code I used to query all available data
Response.Write("<b>ServerVariables</b><br>____________________________<br>");
foreach (string itm in Request.ServerVariables){
if(Request.ServerVariables[itm].ToString().Trim().Length > 0){
Response.Write(itm + " : " + Request.ServerVariables[itm] + "<br><br>");
}
}
Response.Write("<b>Headers</b><br>____________________________<br>");
foreach (string itm in Request.Headers){
if(Request.Headers[itm].ToString().Trim().Length > 0){
Response.Write(itm + " : " + Request.Headers[itm] + "<br><br>");
}
}
Response.Write("<b>Params</b><br>____________________________<br>");
foreach (string itm in Request.Params){
if(Request.Params[itm].ToString().Trim().Length > 0){
Response.Write(itm + " : " + Request.Params[itm] + "<br><br>");
}
}