PDA

View Full Version : Need a way to 301 redirect http://mysite.com/index.htm to http://www.mysite.com/index.htm


mluirette
08-23-2006, 02:25 AM
I'm trying to find an easy way to 301 redirect the default page of an HTML website from http://example.com/index.htm to http://www.example.com/index.htm.

How would I set up an ASP or ASPX file to do this?

All posts in the forum say to "put this in your global.asax", and any time someone asks "what's that?" they say, "oh, you can only do that with asp".

Anyone find an easy way to do this? I didn't realize this would be such an issue moving from an apache server. I'm going crazy trying to keep link partners to remember the WWW!

Any help at all would be greatly appreciated!! thx in advance.http://community.discountasp.net/emoticons/freaked.gif

bruce
08-23-2006, 06:02 AM
See this


http://www.webconfs.com/how-to-redirect-a-webpage.php


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

bruce
08-24-2006, 12:45 AM
unfortunately, this is not possible because www.domain.com (http://www.domain.com) and domain.com are just host header of the same site.


What you need to do is to create some logic w/ ASP or ASP.NET to redirect appropiately.


We can, if you wish, remove the host header for domain.com. This means only www.domain.com (http://www.domain.com) will work.


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

mluirette
08-24-2006, 01:31 AM
Thanks for the quick answer Bruce!


Unfortunately, we need the www.domain.com (http://www.domain.com) AND domain.com to work for the same page somehow without it looking like two duplicate pages. Customers use the domain.com, link partners use both (arg!), one version ranks well, and the other doesn't, it'sa mess! We can't lose half the link pop due to a technical glitch. We need to combine the two with a 301-redirect somehow. I want the non-WWW version to appear as "permanently moved" to the WWW when spiders come crawling around and to transfer pagerank.


Any examples on how to put together something like this? Something I could look at, modify, and upload would be great! Sorry for being a novice at ASP.net, but what goes in the Global.asax file, where do I put it on the server, and how do I call up the subroutine from the page? Is there a basic Global file I can upload and modify?


It seems like there should be tons of examples of other people fixing this problem, and I've found working examples, but I can't seem to find a complete set of instructions.


I found this post through google: http://community.discountasp.net/default.aspx?f=5&m=8525


On the reply from "markus", there's this code for the global.asax file:


'Check for www
If Request.Url.ToString.IndexOf("www.") < 0 Then


Dim mypage As String = Request.Url.ToString.Insert(Request.Url.ToString.I ndexOf("//") + 2, "www.")


'Check if URL is like http://mysite.com/default.aspx (You want to have consistent linking / redirecting. Therefore we cut off
the "/default.aspx" bit)


If myPage.ToLower.EndsWith("/default.aspx") Then
myPage = myPage.Substring(0, myPage.IndexOf("/default.aspx"))
End If


Response.Redirect(myPage)
Response.StatusCode = 301


'The restof the global.asax should be ignored as events will be fired again after the redirect....
Exit Sub
End If


Where does it go in the file? I can't get it to work. How do I call the file from an aspx page?


Thanks again in advance! Sorry for all the questions.


-Mike

joelnet
08-24-2006, 10:52 AM
Try putting the code in the Application_BeginRequest in the global.asax

<script language="vb" runat="server">
Sub Application_BeginRequest(Sender as Object, E as EventArgs)
...
End Sub
</script>


<script language="C#" runat="server">
void Application_BeginRequest(object source, EventArgs e) {
...
}
</script>



Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

mluirette
08-24-2006, 11:46 AM
OK, I'd love to do that, DiscoutASPhas access to the server but already told me this is not allowed in ashared environment. I need to accomplish this task somehow:
IIS Redirect
<UL class=defaultfont>
In internet services manager, right click on the file or folder you wish to redirect (http://signs4success.com/ (http://signs4success.com/))
Select the radio titled "a redirection to a URL".
Enter the redirection page (http://www.signs4success.com/ (http://www.signs4success.com/))
Check "The exact url entered above" and the "A permanent redirection for this resource"
Click on 'Apply' [/list]
Please repeat for each non-WWW version ofall thesehttp://www.bootycocktails.com/, http://www.divasfashions.com/, http://www.divascostumes.com/,http://www.bootdungeon.com/ , http://www.mistersprockets.com/, http://www.hbdentalimplants.com/.

This is why I'm frustrated. Is this possible to get DiscountASP to do this?

If not, how can I get the same effect with HTML/Javascript pageson their server?

Can I at least get the non-WWW versions of the URLs to land on a different page so I can usea simple Javascript code to accomplish this?

Thank you!

mluirette
08-25-2006, 12:06 AM
Hi Joel -

The only thing in the global.asax is the code I copied here below. I have no idea what else is supposed to be in a global.asax file, because all the sites are HTML and I never had one to begin with.

I need to start at super-dumb level and work my way to something workable for at least the index page, I don't even care if the other pages won't do this!

1. How do I make and where do I put the global.asax file
2. Where do I put the code below in the global file
3. How do I convert a standard HTML page into an ASPX page that will pull up this code and work?

I just need to get this one task done, then I'll have all the time in the world to learn ASP.net and leave you guys alone. Thank you for being so patient!

Here's the only thing I could find to supposedly do what I need to do. If there'sa better way, please tell me I'm wrong and correct me:



'Check for www
If Request.Url.ToString.IndexOf("www.") < 0 Then


Dim mypage As String = Request.Url.ToString.Insert(Request.Url.ToString.I ndexOf("//") + 2, "www.")


'Check if URL is like http://mysite.com/default.aspx (You want to have consistent linking / redirecting. Therefore we cut off
the "/default.aspx" bit)


If myPage.ToLower.EndsWith("/default.aspx") Then
myPage = myPage.Substring(0, myPage.IndexOf("/default.aspx"))
End If


Response.Redirect(myPage)
Response.StatusCode = 301


'The restof the global.asax should be ignored as events will be fired again after the redirect....
Exit Sub
End If
Thanks again!
-Mike

joelnet
08-25-2006, 12:38 AM
1. I still need you to paste your global.asax here...
2. Your code should replace the '...' in one of theApplication_BeginRequest methods.
3. I don't understand this question.


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

mluirette
08-25-2006, 01:07 AM
Sorry, but my biggest problem is I don't have a global.asax file, or any "Application_BeginRequest" methods.


I have plain-old html files and I just need to 301 redirect from http://xyz.comto http://www.xyz.com, but I keep being told your server can't do this. Now I need to find some workaround, and I don't care how, just something I can integrate into an html plain-old static page website.


Lets start from the beginning so we're talking about the same thing here: How do I 301-redirect a url missing the WWW to a url with the WWW?


Everyone in the forums and in tech support keeps telling me I need to do something "programmatically" to fix it. Is there a way to do this programmatically in a static HTML file? The next answer I received was I need to convert to ASP.net to make this work. This is where question #3 came from.


I keep getting the same answer to put stuff in my global file, and then we go around in circles again.


I really don't want to change services, and I think your the best host I've had, but this is a MAJOR problem if it can't be fixed somehow. Every other hosting company I've had utilized some sort of search-engine-friendly redirect to avoid this problem. Isn't there anything similar to an htaccess file in IIS or something to fix this without going through all this?


I copied the only thing I had, which was the same code I found in the old forum posting.
If this isn't what you need, please tell me where to get it and I'll find one somewhere.


Thanks!


-Mike

vvsharma
08-25-2006, 10:55 AM
You may map you htm pages to aspx.You may issue a ticket to the DASP support for this.You could then create a global.aspx.

Vikram

DiscountASP.NET
www.DiscountASP.NET (http://www.discountasp.net/)

mluirette
08-25-2006, 11:35 AM
So, please tell if I'm getting this right:

I take the code sample I found and save it in a file called "global.asax" and upload to the server.
Next I take this:


<script language="vb" runat="server">
Sub Application_BeginRequest(Sender as Object, E as EventArgs)
...
End Sub
</script>


<script language="C#" runat="server">
void Application_BeginRequest(object source, EventArgs e) {
...
}
</script>

and insert in somewhere (above the <html> tag?) in the current "index.htm" file and rename itto "index.aspx"?

I get a error: Parser Error Message: The content in the application file is not valid.

Probably because I'm not even close to doing this right!
What else am I missing?

Thanks again!
-Mike

joelnet
08-25-2006, 11:36 AM
post your global.asax file here, I'll help you debug.


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

mluirette
08-26-2006, 04:15 AM
Eventually we'll be migrating portions of the store to ASP.net. For now, we need the HTML pages.
It would be great if I could get the two to co-exist on the same server with proper URL forwarding.


We can't afford risking the nameserver switch with our busy season coming up, otherwise I'd switch immediately then come back when the ASP is ready. From experience, this could cause a temporarylossof our positioning completely from the search engines, especially Google. The last changeover I saw was sales-death.


What will I expect to see as an effect of "mapping HTM pages to ASPX"?
Will the URL change to a .aspx file? If this is the case, I'll lose the advantage of doing this to begin with because it'll be seen as a different URL, or worse, duplicate content.http://community.discountasp.net/emoticons/sad.gif
Well, thanks for all the help, but it looks like this will not be practical for us. I guess I'll have to keep hunting down link partners and correcting them!

If mapping means keeping the .htm extensions, that'll be awesome! Let me know....

-Mike

mluirette
08-26-2006, 04:20 AM
Oh, BTW Joel, when I said "super-dumb" I was referring to ME, not you! Just in case that's what prompted the harsh reply. Thanks man! http://community.discountasp.net/emoticons/blush.gif

bruce
08-26-2006, 11:51 AM
i have to be honest w/ you, if you have just plain old static page site, why are you hosting your site on our server?


Not that we don't want your business but I am speaking from a technical perspective. If you do not need ASP or ASP.NET technology, you are better off hosting your static site on an UNIX box where you can easily perform URL Rewriting.


The way I look at it is simple, there is no ultimate platform out there, you choose the most suitable platform for your every need. I can tell you that if you have a plain old HTML site, you better off hosting it on a UNIX platform.


Changing .html mapping will definintely work but you also need to write a custom HTTP Handler in ASP.NET to handle the HTML page.


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

bruce
08-27-2006, 05:29 AM
mluirette said...




What will I expect to see as an effect of "mapping HTM pages to ASPX"?
When we map an extension to ASP.NET, the page will be processed by the ASP.NET processor. In another, you cancreate a custom HTTP Handler in your application to do whatever you want with the page.




mluirette said...
If mapping means keeping the .htm extensions, that'll be awesome! Let me know....Yes. Technically, this is possible.

I found some reference that may help

http://www.15seconds.com/issue/020417.htm
http://geekswithblogs.net/flanakin/articles/HttpHandlers.aspx
http://www.developerfusion.co.uk/show/4643/


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

mluirette
08-27-2006, 05:44 AM
Great! Thank you for all the help...


Since my ASP guy won't (or can't!)help with this, we're about ready to tell him and his cart to take a hike.
We're weighing our options at this time, but if we stick with the plan to migrate to ASP.net I'll definitely use the advice.


Keep up the good work, and thanks again for putting up with my ramblings! It's much appreciated.


-Mike

bruce
08-29-2006, 01:32 AM
No problem!!


This google problem is bugging a lot of people and we are also trying to find ways to make it easier for our customer.


The big problem is that URLRewriting is not part of IIS and it requires some pretty hard core programming ability to write your own rewrite tool.


Good luck!

Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

edified
11-06-2006, 04:51 AM
Any update on 301 Redirects? I'd like to make www.brockhuman.com (http://brockhuman.com/) and all subsequent URIs always redirect to brockhuman.com (http://brockhuman.com/).

How about just letting us set different folders for different sub-domains. Then a proper 301 is a simple PHP, or ASP (I assume) file away!

Thanks, Ed

edified.org (http://edified.org/)

bruce
11-06-2006, 08:22 AM
unfortunately, it doesn't work this way.


the hostname and www.hostname are just simply host header in the IIS virtual server, and they are technically equivalent.


If we give different sub directory w/ each hostname, that means we have to setup multiple virtual server which requires a complete change in architecture.


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

edified
11-08-2006, 08:19 AM
What about disabling www.brockhuman.com (http://brockhuman.com/) and just leaving brockhuman.com (http://brockhuman.com/)? is that possible?

Thanks, Ed

Ed Palma (http://edified.org/resume) - edified.org (http://edified.org/)

Aristotle
11-09-2006, 01:51 AM
We can do that. Create a support ticket.

Although you should alsoremove the www "A Record" in the DNS Manager so that it won't get resolved to the default site on the server, which displays a generic "web page unavailable" page.

Aristotle

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

WebGuy
03-15-2007, 04:16 AM
Does anyone have an update to the 301 redirect issue?

If DiscountAsp cannot come up with a good solution,they willhave a serious competetive disadvantage to other .NET framework hosting companies. SEOs will definitely think twice before useing DiscountAsp hosting, as others who specialize in .NET hosting offer a solution to 301 redirect.

Please advise. Thanks.

bruce
03-20-2007, 12:39 AM
The problem is not related to a 301 redirect problem. The problem is that both www.domain (http://www.domain) &amp; domain is the SAME site (they are just different host header).


I think almost all hosts have the same problem.


Bruce

DiscountASP.NET
www.DiscountASP.NET (http://www.DiscountASP.NET)

PRB
03-20-2007, 06:22 AM
GW said...

Does anyone have an update to the 301 redirect issue?

If DiscountAsp cannot come up with a good solution,they willhave a serious competetive disadvantage to other .NET framework hosting companies. SEOs will definitely think twice before useing DiscountAsp hosting, as others who specialize in .NET hosting offer a solution to 301 redirect.

Please advise. Thanks.What .NET host provides the ability to use the 301 redirect on their shared servers?

WebGuy
03-20-2007, 07:24 AM
At this time, I do not know of any. If I did I would probably be using their services - all things being equal.


It looks to me like this is a rather large opportunity for some hot shot.NET hosting co. (like DiscountAsp) to create a good solution. What with all the concern google has createdabout duplicate content (www.mysite.com (http://www.mysite.com) and mysite.com).


That you ask the question, makes my point. http://community.discountasp.net/emoticons/smilewinkgrin.gif

joelnet
03-20-2007, 10:02 AM
Here is the solution...

Contact support and have themmap all .htm and .html pages to the ASP.net ISAPI.

Create a new file called global.asax...

[quote]

<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e) { }
void Application_BeginRequest(object source, EventArgs e) {

string redirectFrom = "www.localhost (http://www.localhost/)";
string redirectTo = "localhost";

if (String.Compare(Request.ServerVariables["SERVER_NAME"], redirectFrom, true) == 0) {
Response.Redirect(
String.Format("http{0}://{1}{2}{3}",
Request.IsSecureConnection ? "s" : "",
redirectTo,
Request.Url.Port != 80 ? Request.Url.Port.ToString() : "",
Request.Url.PathAndQuery
));
}

}

void Application_End(object sender, EventArgs e) { }
void Application_Error(object sender, EventArgs e) { }
void Session_Start(object sender, EventArgs e) { }
void Session_End(object sender, EventArgs e) { }


</script>
</CODE>
Modify the values for redirectFrom and redirectTo to your desired values.

Hrm... I think that's all!


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

WebGuy
03-21-2007, 03:28 AM
That was fast! I'll implement the code later today. Thanks.

WebGuy
03-21-2007, 03:39 AM
Joel - could you translate that into VB? Please.

WebGuy
03-22-2007, 12:23 AM
Hi Joel - well there two reasons I asked:


1) As I understand it, I can only use one language in the global.asax file, and I will be adding more code (in VB) later.


2) I would like to better understand what your code does.


Thanks

joelnet
03-22-2007, 09:20 AM
[quote]

Dim redirectFrom As String = "www.localhost (http://www.localhost/)"
Dim redirectTo As String = "localhost"

If (String.Compare(Request.ServerVariables("SERVER_NAME"), redirectFrom, true) == 0) Then
Response.Redirect(
String.Format("http{0}://{1}{2}{3}",
IIf(Request.IsSecureConnection, "s", ""),
redirectTo,
IIf(Request.Url.Port != 80, Request.Url.Port.ToString(), ""),
Request.Url.PathAndQuery
))
End If</CODE>








Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

joelnet
03-22-2007, 11:03 AM
If you're running asp.net 2.0, you should be able to run both C# and VB.NET in the same web application.


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

WebGuy
03-23-2007, 04:33 AM
Well Joel, I implemented the VB version of thecode you supplied above. Using VWD 2005 Express two errors were indicated. Here is the code as Icorrected it(correctly, I hope) and placed in my global.asax file:


-----


Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)


Dim redirectFrom As String = "localhost"


Dim redirectTo As String = "www.localhost"





If (String.Compare(Request.ServerVariables("SERVER_NAME"), redirectFrom, True) = 0) Then


Response.Redirect(String.Format("http{0}://{1}{2}{3}", _


IIf(Request.IsSecureConnection, "s", ""), _


redirectTo, _


IIf(Request.Url.Port <> 80, Request.Url.Port.ToString(), ""), _


Request.Url.PathAndQuery))


End If





End Sub


-----


I changed the "== 0" to "= 0", and the "!= 80" to "<> 80".


Unfortunately, when I open a new browser and enter either www.mydomain.com (http://www.mydomain.com) or mydomain.com, I am NOT rediredted to my prefered www.mydomain.com (http://www.mydomain.com).


Please help.

joelnet
03-23-2007, 10:49 AM
Put this code inside Application_BeginRequest


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

WebGuy
03-24-2007, 10:33 AM
Hello Joel -


I did as you suggested immediately above, and then stopped and restarted the site in the Control Panel, to no avail. When I enter http://mysite.com, the site doesNOT redirect to http://www.mysite.com.


By the way, once this code works, will typing in the mysite.com return a 301 error, when it redirects to www.mysite.com (http://www.mysite.com)?


Also,will using the code introduce any performance issues?
I am eager to see this code work, and appreciate your assistance.

joelnet
03-26-2007, 08:23 AM
GW said...



Hello Joel -


I did as you suggested immediately above, and then stopped and restarted the site in the Control Panel, to no avail. When I enter http://mysite.com, the site doesNOT redirect to http://www.mysite.com.


By the way, once this code works, will typing in the mysite.com return a 301 error, when it redirects to www.mysite.com (http://www.mysite.com)?


Also,will using the code introduce any performance issues?
I am eager to see this code work, and appreciate your assistance.



Every request is now intercepted and tested, though this performace loss should not be measurable.


The redirect will appear seemless from the viewers point of view.


Please paste your whole global.asax (with vb or cs) so I can look at it.


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

WebGuy
03-26-2007, 09:16 AM
Hello Joel -

The entire Global.asax file appears between the dash lines below:

----------

<%@ Application Language="VB" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim redirectFrom As String = "localhost"
Dim redirectTo As String = "www.localhost (http://www.localhost)"

If (String.Compare(Request.ServerVariables("SERVER_NAME"), redirectFrom, True) = 0) Then
Response.Redirect(String.Format("http{0}://{1}{2}{3}", _
IIf(Request.IsSecureConnection, "s", ""), _
redirectTo, _
IIf(Request.Url.Port <> 80, Request.Url.Port.ToString(), ""), _
Request.Url.PathAndQuery))
End If
End Sub

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
' Note: The Session_End event is raised only when the sessionstate mode
' is set to InProc in the Web.config file. If session mode is set to StateServer
' or SQLServer, the event is not raised.
End Sub

</script>

----------

When googlebot visits (after this code is working) it needs to see a 301 header indicating that the file (mysite.com/somepage) has been permanently moved (to www.mysite.com/somepage (http://www.mysite.com/somepage)). That is what SEO types are concernte about.

Thanks in advance for your assistance.

joelnet
03-26-2007, 10:11 AM
Dim redirectFrom As String = "localhost"
Dim redirectTo As String = "www.localhost (http://www.localhost/)"


did you change these lines?


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET

WebGuy
03-27-2007, 02:21 AM
Hello Joel -

No I had not changed out the localhost to mysite.comand www.localhost (http://www.localhost) to www.mysite.com (http://www.mysite.com). When I did I got the following results:

1) when I typed in "www.mysite.com (http://www.mysite.com)" I was taken to "http://www.mysite.com". Good.

2) when I typed in "www.mysite.com/somepage.aspx (http://www.mysite.com/somepage.aspx)" that is what I saw. Good.

3) when I typed in "mysite.com" I was taken to "http://mysite.com/" very briefly (long enough to read the URL) and then onto"www.mysite.com/default.aspx (http://www.mysite.com/default.aspx)". Good and BAD.

4) when Ityped in"mysite.com/somepage.aspx"I was immediatelytaken to"http://<a target="_blank" href="http://www.mysite.com/somepage.aspx">www.mysite.com/somepage.aspx (http://www.mysite.com/somepage.aspx)</A>". Good.

Theproblem remains at two levels:

1) the whole purpose of this code is to avoid the "duplicate page" issue raised by Google (Google treates www.mysite.com (http://www.mysite.com) and mysite.com as two different pages with identical content. It includes both pages in it's index. The one with the higher pagerank is generally the one that will get the better ranking. This introduces many difficulties for SEOs who are concerned about ethically getting the highest possible ranking in the search results for target search phrases.) When the googlebot visits "mysite.com" we want to return a 301 (page permanently moved) error code before the redirect. This is so Google will remove "mysite.com" pagesfrom their index - and all is well.

2) the duplicate page issue cancome into playwhenthe default page within the root, or any subfolder, is sometimes referenced byby thefolder, not the specific default page. This is to avoidGoogle indexing both"www.mysite.com/ (http://www.mysite.com/)" and "www.mysite.com/default.aspx (http://www.mysite.com/default.aspx)" (or .htm or .html or .index, etc). In #3 above your code automatically redirects from "mysite.com" to "http://www.mysite.com/default.aspx". This introduces a potential "duplicate page" issue on the most important page ofmost web sites - the home page.

The issue boils down to this:

Is there a way the code can redirect from "mysite.com" to "http://www.mysite.com/ (http://www.mysite.com/)" without including the reference to the specific default page?

Can the redirection of default pages at thesubfolder level, be to the folder instead of including the specific default page of that folder?

Can your code be made to return a 301 error before redirecting?

Please advise. Thanks.

PS: Did you know that "localhost" works just fine in the code used to send email via smtp? That is why I assumed that you meant for me to use "localhost" instead ofme domain name in this case.

WebGuy
03-27-2007, 08:48 AM
Hello Joel -


Regarding my post immediately above, here is what is returned when I type "mysite.com" into a new browser window:


HTTP/1.1 302 Found
Connection: close
Date: Tue, 27 Mar 2007 21:42:22 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: http://www.mysite.com/default.aspx
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 153
I need your code to return"HTTP/1,1 301 Permanently Moved" instead. That way Google notes that the "mysite.com" no longer exists, and Google drops it from their index.

Please help me.

joelnet
03-27-2007, 09:15 AM
302 and 301 should have the same effect in google. When google attempts to crawl the page, it will get a 302 and remove it from the index. Because there is no content on this page, it cannot be added to the search engines index.


If you want to send a 301, you have to do it manually.


Replace the Response.Redirect line with these 3 lines...


Response.StatusCode = 301;
Response.AddHeader(
"Location",
String.Format("http{0}://{1}{2}{3}",
Request.IsSecureConnection ? "s" : "",
redirectTo,
Request.Url.Port != 80 ? Request.Url.Port.ToString() : "",
Request.Url.PathAndQuery
));
Response.End();


Joel Thoms
DiscountASP.NET
http://www.DiscountASP.NET