Forum Moderators: open

Message Too Old, No Replies

Alternative 301 Redirect - Windows Server

301 Redirect Windows Server

         

UKSEOconsultant

1:53 pm on May 23, 2006 (gmt 0)

10+ Year Member



Hi,

We have two indentical webpages on our site and nneed to perform a redirect in order to avoid duplication issues and transfer the PR of the redirected page;

Index1.html - Old page, PR4
Index.html - New homepage, duplicate of index1.html, PR2

We need to perform a 301 redirect from Index1.html to index.html however our hosting company are not willing to setup a 301 redirect in IIS.

I think however i have found an alternative solution;

If we insert the following code into the redirected page (index1.html) will this have the desired effect?

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently" Response.AddHeader "Location", " http://www.example.com/index.html"
>

Many thanks in advance!

Lee

[edited by: pageoneresults at 2:02 pm (utc) on May 23, 2006]
[edit reason] Examplified URI Reference [/edit]

ctudorprice

2:41 pm on May 23, 2006 (gmt 0)

10+ Year Member



yup - should do. you might want to add Response.End after but that's optional.

pageoneresults

2:44 pm on May 23, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here's the ASP.NET version just in case...

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.example.com/new-page.asp");
}
</script>

UKSEOconsultant

4:36 pm on May 23, 2006 (gmt 0)

10+ Year Member



Cheers guys, just wanted to confirm before implementing!

That's one headache over... now for the rest!

mrMister

3:40 pm on May 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Definitely put a Response.End as the last line. Otherwise, if you have additional code on the page, the server will be doing much more processing than it needs to.

UKSEOconsultant

4:25 pm on May 24, 2006 (gmt 0)

10+ Year Member



Cheers Guys,

I'm having major problems with this 301 none - of the above methods seem to work on <edited>. Don't think I'm inserting the script in the wrong place.

I think the main reason I'm having problems is the control we have over the server, or lack of it. I think we may need a server side script to take care of things.

Obviously the page we have is HTML which means that the server wont run server side code only client side.

Any thoughts?

[edited by: tedster at 5:17 pm (utc) on May 24, 2006]

UKSEOconsultant

2:12 pm on May 25, 2006 (gmt 0)

10+ Year Member



Sorted it guys, many thanks!

For future reference;

I used a httpd.ini file in the wwwroot folder, making use of ISAPI Rewrite.

Thought I’d let you know.

Cheers, Lee

pageoneresults

2:22 pm on May 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ah-ha, the ISAPI_Rewrite version...

RewriteCond Host: ^example\.com
RewriteRule (.*) http\://www\.example\.com$1 [I,RP]

mrMister

3:06 pm on May 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For future reference;

I used a httpd.ini file in the wwwroot folder, making use of ISAPI Rewrite.

Did you not think of mentioning that you rewriting software installed when you wrote your original post?

Wanted: Psychics to reply to WebmasterWorld posts. :p

UKSEOconsultant

3:40 pm on May 25, 2006 (gmt 0)

10+ Year Member



The host has just told me this.. would be good to have known earlier!