March 17, 2008

301 Redirects on IIS Servers

Posted at March 17, 2008 07:12 AM

As most of you know, I don't do IIS. It's a personal choice I've made for reasons that I won't bother going into now. That said, setting up redirects in IIS is a completely animal than it is with a *nix/Apache server.

One way to accomplish the task on an IIS server is to install ISAPI Filters. The ISAPI Dyanmic Link Library functions much the same .htaccess does in an Apache environment, to the point that many .htaccess rewrite syntax can be used without alteration in ISAPI.

The main issue with ISAPI being that unlike .htaccess many ISAPI extensions are going to cost you real money. Since ISAPI runs as an application on IIS there is often a cost involved for the webmaster in order to utilize them. The other issue being that if you're on a shared IIS server you often won't have enough control to install ISAPI filters yourself. And many hosts balk at installing them for reasons of their own.

A classic catch-22 situation.

Just because you're on an IIS server doesn't necessarily mean you cannot employ rewrites and redirects though. Though I don't dabble in IIS rewrites personally, Chris Hirst --who I hang out with over at the HR Forums-- is an IIS guru and has come up with several differnt ways one can accomplish what I do with .htaccess on IIS servers. For completeness, here are some links to his ideas.

Tweaking the Application Mappings in IIS - This will allow you to have pages with one extension treated as if they were files carrying another extension. So if you need .htm pages to be parsed as if they were .asp, this is the one you'll want.

Handling www/non-www issues in ASP - This snippet of code is something Chris developed to deal with www and non-www requests when you have a .asp site. It is code that is run at the Script or File level, but is dynamic. One note: The original code Chris posted in reply #4 does not account for variables in the URL string. If you have a dynamic ASP site that needs help with www/non-www issues, look a bit farther along in the thread. In post 22 on page 2 Chris provides a code snippet that will take care of query strings.

Using a Smart 404 Page - A Smart 404 is basically a method you can use when you have pages that are changing location and you want to make sure the link pop the old page had accrued gets passed along to the new page. What happens is everyone (spiders included) initially gets sent to the custom 404 page when they request a file that no longer exists. Then the custom (smart) 404 runs through a small bit of code to decide if it should really deliver a 404 Not Found response or if it should instead deliver a 301 Moved Permanently response, sending the visitor on to the correct page. This can be very, very effective regardless of the extension your site files use, because you can always set your IIS server to display an asp file as your custom, smart 404 page. All it requires is that you enter your page uri's (relative path from root) at the top of the code. The script then does all of the heavy lifting for you.

If the above references do not address your specific situation or if you have an IIS redirect problem that you can't sort out, by all means feel free to post your question in the Technology & Coding > Redirects portion of High Rankings Forum and someone will be by to help you sort it out.

Trackback

You can ping this entry by using http://www.randycullom.com/chatterbox/mt-tb.cgi/37 .

Comments

Post a comment










Remember personal info?