View Full Version : 301 redirect on win server with html pages
srikanthsh
09-02-2004, 15:10/03:10PM
Hello,
We have website hosted on win server. All the pages were .shtml pages except few pages for the forms. We recently redesigned the site. Now all the pages are html and few asp pages.
Now, from search engines, people access the old pages. That's why we have to make a 301 redirect. I know that we can do 301 redirection using response object's header and location properties (This script can be embedded in asp pages to make a 301 redirect). But, many of my site pages are .html and i have to make 301 redirect.
Could anybody help me, please. Thanks for your time.
iTISTIC
09-02-2004, 18:43/06:43PM
You can setup IIS to process your .html files with the ASP parser. Then you could put ASP code in the html files to do the same as your ASP files.
polarmate
09-02-2004, 22:47/10:47PM
Do you have admin access to your web server? If you don't then getting a web host to set up a page by page 301 redirect will be difficult and it is also very likely that they will mess up. (Ask me!! I've been there!!)
What you can do is write a 404 handler in ASP instead such that when a visitor tries to reach you using the old pages, the 404 error is trapped by the 404 handler which then redirects to the new page while issuing a 301 http status. You can store the old page to new page mapping in a database and use that to redirect your visitors. If the 404 is due to a page not in the database then show your standard 404 error message with links to important parts of your web site and/or your site map to help the visitor find their way.
Don't forget to ask your web host to set your custom 404 handler to the 404 ASP page you code.
There is a thread that you can refer to for more information on how to do a 301 redirect using a 404 handler here:
http://www.ihelpyouservices.com/forums/showthread.php?s=&postid=106363#post106363
Although that is for a URL rewrite, the concepts remain the same.
HTH!
srikanthsh
10-02-2004, 10:38/10:38AM
Thank you all. I sent an email to my server people to set a 404 handler.
Webmaster T
10-02-2004, 12:14/12:14PM
Originally posted by iTISTIC
You can setup IIS to process your .html files with the ASP parser. Then you could put ASP code in the html files to do the same as your ASP files.Could you elaborate please? I have a site that I'm changing all the .htm to asp but if I can get the server to treat the .htm as .asp so I can add some dynamic ads to the pages this would make implementation much easier with less chance of losing links to the pages. It sounds like it has something to do with the server setup which I have full access to. There are other sites on the server would they be affected as well and how. Do youy know any documentation on this?
iTISTIC
10-02-2004, 12:50/12:50PM
Originally posted by Webmaster T
Could you elaborate please? I have a site that I'm changing all the .htm to asp but if I can get the server to treat the .htm as .asp so I can add some dynamic ads to the pages this would make implementation much easier with less chance of losing links to the pages. It sounds like it has something to do with the server setup which I have full access to. There are other sites on the server would they be affected as well and how. Do youy know any documentation on this?
You can make it affect every site on the server if you wish, but can also apply it to only specific sites. I do not have any documentation on it, but it should be included in any complete IIS documentation you would find online or elsewhere. In any case, to do this just perform the following:
1) Open up IIS
2) Right click on the web site you would like to implement this feature on, and select Properties.
3) Click on the Home Directory tab.
4) Click on the Configuration button near the bottom right hand corner of this tab.
5) Scroll through the list box and make sure the .htm (or .html depending on what you are changing) is not already listed there. If it is, please let me know what it's settings are before continuing.
6) Click the Add button.
7) For the executable, put the following:
C:\WINNT\System32\inetsrv\asp.dll
8) For the extension, put .htm (or .html if that is what you wish to have processed by the ASP parser)
9) Make sure All Verbs is selected, along with Script engine
10) Click OK
11) Click OK
12) Click OK
Now if you add some ASP code to one of your .htm pages you will see it will be parsed and executed by the ASP engine.
Webmaster T
10-02-2004, 12:55/12:55PM
Thanks so much!! You just saved me hours of work! I presume if there is no .asp scripting the page is just rendered as is.
polarmate
10-02-2004, 13:19/01:19PM
What are the possible pitfalls of doing this? (Apart from the usual ones about server load while spidering because a dynamic site is presented as a static one.)
iTISTIC
10-02-2004, 13:44/01:44PM
Originally posted by polarmate
What are the possible pitfalls of doing this? (Apart from the usual ones about server load while spidering because a dynamic site is presented as a static one.)
The only pitfall lies in the fact that now instead of IIS just serving up your HTM pages, it is not sending them through the ASP parser first, which will obviously take up some CPU time, etc. The difference will be extremely minimal, especially if there is no ASP code on the page that is being requested.
If you could go the other route and rename all of your dynamic files to ASP, and leave your static files as HTM, that of course would be the BEST way if you are solely considering resource usage. For me, I always name my static files even .ASP (on ASP projects) or .ASPX (on .NET projects) only because they are always part of a site that has a common header and footer. I accept the fact that these pages will use more resources, but will be a lot easier to maintain.
The choice is all yours. I have done this on servers that receive hundreds of thousands of requests per day and have not had any problems what so ever, and saw no noticeable decrease in performance.
iTISTIC
10-02-2004, 13:46/01:46PM
Originally posted by Webmaster T
Thanks so much!! You just saved me hours of work! I presume if there is no .asp scripting the page is just rendered as is.
This is correct Mr. T. The ASP parser will still parse the file, but no scripting will be performed as there will be no script in the file. Just as long as you understand ALL of the .htm files (with or without script) will go through the ASP parser before being sent down to the client's browser.
Webmaster T
10-02-2004, 13:47/01:47PM
Manisha, I just got off the phone with my brother (server admin) he was kicking himself for not figuring this out himself. I was concerned that .asp would not be parsed but it seems you can use more than one extension associated with the executable similar to how you set up .cgi,.pl, and .plx for the perl parser. An .htm file with no asp scripting would be rendered as usual.
IMO, this is the answer to a number of problems associated with changing htm to asp. There would be a little extra overhead for .htm pages with no .asp but it would not affect most sites too much or make it a big overhead problem.
IMO, The problems with spiders and dynamic sites seems to be lack of adequate hardware (processing power) and ODBC connections that aren't killed immediately after the recordset is processed or put into memory. I believe if a site is adversely affexcted by spidering there are way bigger issues then the spiders. The server/bandwidth isn't adequate or the site scripting isn't tuned for big spikes in traffic.
polarmate
10-02-2004, 14:01/02:01PM
He! he! It took my techie husband by surprise, too. I should have made a bet with him before I let him try it out!!
T, I had a problem with one of my web sites last year where the database was shut down by the host. It was just the AtomZ spider hitting the site. They make 10 concurrent parallel connections and for the free setup, they don't offer any spider 'slow-down.' It was not so much a hardware issue as an alert that the admin received as they are always on the 'lookout for various ways in which their servers may be attacked.' The site is actually quite busy and AtomZ was there for about 15 minutes. None of the pages showed an error - at least in the logs all were showing 200 or 304. The bandwidth was not excessive but the database hits seemed to have triggered some alert because of which the Admins moved in and shut it down.
I doubt I would parse my htm files using the ASP parser unless I absolutely had to. However, this is certainly something that is very useful to know and it is a workaround in a tight situation when you have full access and control to the server. Thanks, Shawn! :)
iTISTIC
10-02-2004, 14:37/02:37PM
Anytime, guys/gals. Glad to be of some help. Feels good to give back the community which I am trying to learn so much from ;)
Please keep me in mind if you ever need any server management, database design/management, or programming work!
Thanks again.
vBulletin® v3.8.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.