High Rankings Search Engine Optimization ForumHigh Rankings Advisor Search Marketing Newsletter

Welcome Guest ( Log In | Register )

Important Announcement: ***Need an Affordable SEO Website Review?***
2 Pages V   1 2 >  
Reply to this topicStart new topic
> Windows 301 Code, I've tried standard methods with no luck
qwerty
post Feb 12 2006, 08:30 PM
Post #1


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



I need to redirect a bunch of .html pages on a Windows server to .asp pages. Some of them will be pointing to the same URL, but with a different file type, but most won't. I don't have access to the management console, so I've been trying VBScript, JScript, and C# with no success.

Here's what I've got: I created a page called redirect.html, and I've tried using the following code to redirect it to the home page (domain name changed to protect the innocent):
CODE
<script runat="server">
private void Page_Load(object sender, System.EventArgs e) {
   Response.Status = "301 Moved Permanently";
   Response.AddHeader("Location", "http://www.domain.com/");
}
</script>

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

CODE
function PermanentRedirect(strDestinationUri) {
Response.Clear();
Response.Status = 301;
Response.AddHeader("Location", http://www.domain.com/);
Response.Flush();
Response.End();
}

Either I'm coding this wrong, or the server just won't let me run these sorts of scripts. If the problem is that these pages need to already be .asp, I guess I'm SOL.
Go to the top of the page
 
+Quote Post
jehochman
post Feb 12 2006, 09:40 PM
Post #2


Jonathan Hochman
Group Icon

Group: Moderator
Posts: 1,554
Joined: 27-November 05
User's local time:
Feb 9 2010, 02:24 PM
From: Connecticut - Land of Steady Habits
Member No.: 9,569



Qwerty, I think you are SOL, because as far as I know, the only way to do 301 redirects on IIS is through the server management panel (creating a dependency on the hosting provider), or with an ASP script.

I've asked a hosting company if they could turn on ASP processing for HTML pages. Yes, that's possible, but no, they'd rather not because it creates a security problem. Am I going to take that risk, against advice, and risk hosing the client's server. No.
Go to the top of the page
 
+Quote Post
qwerty
post Feb 12 2006, 11:52 PM
Post #3


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



Figures. I love IIS (IMG:http://www.highrankings.com/forum/style_emoticons/default/yuk.gif)

I guess it's not that big of a deal. The old version of the site had navigation that wasn't SE-friendly, so a number of the pages weren't indexed, and we're expanding the site about threefold. We've got 12 pages we'd have neede to redirect

I suppose we're going to need a custom 404 just in case, though. And I don't know if their host allows for that, either...
Go to the top of the page
 
+Quote Post
chrishirst
post Feb 13 2006, 07:59 AM
Post #4


HR 9
Group Icon

Group: Moderator
Posts: 4,356
Joined: 13-August 03
User's local time:
Feb 9 2010, 06:24 PM
From: Blackpool UK
Member No.: 492



What a load of drivel, having any page extension processed as ASP presents no more security risk than having .asp files processed as ASP does.

The sooner many hosting companies get a clue the better it will be!
Go to the top of the page
 
+Quote Post
qwerty
post Feb 13 2006, 08:34 PM
Post #5


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



There's more. The site has a control panel. I logged in and didn't see anything about redirects or error pages, so I went into the help section and ran a search. Lo and behold, they have complete instructions on how to set up custom error pages.
QUOTE
Once you have clicked on the Customize Your Error Pages button, you will be presented with a pop- up window that allows you to upload your own error pages. One of these pages will be sent to the user if they make a request that the server is unable to fulfill.
...
To customize error pages, follow these steps:

1. First you will need to make the relevant error page.

2. Click on the error code that you wish to customize in the list. This will load the information about the error into the table at the top of the page. The error code will be entered into the Error Code column and any file currently attached to that error code will be shown under the File Name column.

3. Type in the location of the error page (on your hard drive) in the textbox at the top of the window, or click the Browse button to locate the file with an Explorer window.

4. Click the Upload Error Page button when you have located the page. This stores the file information in the list.

5. Click Save into IIS to store the error page, or click Close to discard any unsaved changes and close the pop-up window.

Just one tiny problem: there is no Customize Your Error Pages button (IMG:http://www.highrankings.com/forum/style_emoticons/default/ranting.gif)
Go to the top of the page
 
+Quote Post
qwerty
post Feb 15 2006, 12:01 PM
Post #6


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



Latest news on this little mess:

I've published the site after getting in touch with the host's support department. They told me what to do about the 404 page. I created a page called 404.asp, uploaded to a folder called /errorpages/ and then had to put in a support request for them to set the server to use that page for 404 errors. I've tested it, and in IE and Opera it works fine -- it even returns a genuine 404 response. In Firefox, however, I get a popup asking if I want to download the file (IMG:style_emoticons/default/wacko.gif)

Regarding the 301s, I discussed it with them for about half an hour, and they told me to put in a support ticket for that as well, in the hope that somebody in their department would understand what I'm talking about. So far, no dice. If a user tries to get to services/bat_in_house.html, they're supposed to end up at services/bats/bat-in-house.asp. That's not happening.

This post has been edited by qwerty: Jul 4 2007, 11:46 AM
Reason for edit: Removed links
Go to the top of the page
 
+Quote Post
DianeV
post Feb 15 2006, 02:50 PM
Post #7


HR 4
****

Group: Active Members
Posts: 166
Joined: 25-July 03
User's local time:
Feb 9 2010, 10:24 AM
From: Los Angeles
Member No.: 38



Sorry to say that I've seen these kinds of limitations with Windows servers before.

It appears that things that can be easily done on *nix servers are a big problem on Windows servers. Either that, or the tech people don't understand the issues.

One time, after discussing 301's with a host, the host (!) set up a bunch of meta-refresh pages (!) without being asked (!) or telling anyone (!). Luckily, I happened to FTP into the account and discovered it all.
Go to the top of the page
 
+Quote Post
jehochman
post Feb 15 2006, 03:14 PM
Post #8


Jonathan Hochman
Group Icon

Group: Moderator
Posts: 1,554
Joined: 27-November 05
User's local time:
Feb 9 2010, 02:24 PM
From: Connecticut - Land of Steady Habits
Member No.: 9,569



QUOTE
What a load of drivel, having any page extension processed as ASP presents no more security risk than having .asp files processed as ASP does.


Chris, it's even worse than that. When I asked this hosting company to set up 301's for a bunch of alternate domains they said "301 error codes! You want to intentionally return an error codes? We can't do that!" (IMG:http://www.highrankings.com/forum/style_emoticons/default/mf_tongue.gif)

What do you do with a clueless, know-it-all hosting company when the client refuses to switch?
Go to the top of the page
 
+Quote Post
DianeV
post Feb 15 2006, 03:19 PM
Post #9


HR 4
****

Group: Active Members
Posts: 166
Joined: 25-July 03
User's local time:
Feb 9 2010, 10:24 AM
From: Los Angeles
Member No.: 38



Right. My experience is that Windows hosts usually aren't familiar with the usual terminlogy (e.g., 301 redirect), and so communication can be difficult at best.

In fact, that being the case, it's sometimes difficult even to get them to grasp *why* one might want to redirect an old soon-to-be-dead page to a new URL.

I guess they must live in a perfect world where such things simply aren't needed? <grin>
Go to the top of the page
 
+Quote Post
qwerty
post Feb 15 2006, 03:22 PM
Post #10


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



The client already regrets not switching hosts the last time he renewed his contract. I don't think I'll have any trouble getting him to do it.
Go to the top of the page
 
+Quote Post
Ron Carnell
post Feb 15 2006, 03:32 PM
Post #11


HR 6
Group Icon

Group: Moderator
Posts: 918
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Michigan USA
Member No.: 17



Back in the Nineties, Bob, before there was such a thing as an ISAPI mod-rewrite for Windows, there was a lot of activity at SEF centered on using 404 Traps to accomplish the same thing. I know Mikkel, over at SEW, was active in those early threads and might even have some of the old code laying around?

Essentially, you set up a friendly URL that you want to use, knowing full well it doesn't exist and will generate a 404. Your custom 404 script, however, looks for that friendly URL and, when it see it come in the door, generates a redirect and returns a 301. Anything you don't program into the script falls through and generates a standard 404 response.

If you can't find any other satisfaction, it might be something to consider. (IMG:http://www.highrankings.com/forum/style_emoticons/default/smile.gif)
Go to the top of the page
 
+Quote Post
chrishirst
post Feb 16 2006, 09:30 AM
Post #12


HR 9
Group Icon

Group: Moderator
Posts: 4,356
Joined: 13-August 03
User's local time:
Feb 9 2010, 06:24 PM
From: Blackpool UK
Member No.: 492



should be simple enough to create a "smart" 404 page to handle it, maybe without even delving into the realms of REgEx'ing

The problem with many hosts (*nix and Windows alike) is they buy shared space or a rehosting deal with little or no clue what is involved in running a server.
Go to the top of the page
 
+Quote Post
qwerty
post Feb 16 2006, 10:20 AM
Post #13


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



I'm afraid I don't get what you guys are suggesting. I don't think we can use a custom 404 script if the only way to have a 404 page is to tell the host which page to use as the 404. It seems we don't have the power to fiddle with such things ourselves.

The good news is that G has already indexed the new home page -- it took about 12 hours. So I'm hoping the rest of the site will get picked up quickly and it won't matter.

<edit>OK, they've picked up the new home page on at least one DC. I just checked again and the cache had the old page.
Go to the top of the page
 
+Quote Post
Ron Carnell
post Feb 16 2006, 10:18 PM
Post #14


HR 6
Group Icon

Group: Moderator
Posts: 918
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Michigan USA
Member No.: 17



QUOTE
I don't think we can use a custom 404 script ...

Bob, /errorpages/404.asp already IS a custom 404 script. You can have it do anything that ASP can do, including examine the request that generated the 404 to see if it's one of your special pages and do an on-the-fly redirect if it finds one.
Go to the top of the page
 
+Quote Post
qwerty
post Feb 16 2006, 10:54 PM
Post #15


HR 10
Group Icon

Group: Moderator
Posts: 7,489
Joined: 24-July 03
User's local time:
Feb 9 2010, 01:24 PM
From: Somerville, MA
Member No.: 22



Ah, so it would replace all those others. I'd have to take them down, or the server would respond with a 200 and then display the code it refuses to process.

So how's it work? I build an array of the URLs to be redirected and loop through it, or do I just do a series of if/then statements?
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >   
Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



This forum is sponsored by High Rankings, a Boston SEO Agency
- Lo-Fi Version Time is now: 9th February 2010 - 01:24 PM