Archive for the ‘IIS’ Category

IIS 7 and URL Rewerite

Sunday, March 10th, 2013

I have been using IIS 6 (and some older versions) for a long time for many of the clients website. One of the biggest feature I miss is the URL Rewrite component. Apache support this module for so long, and it’s must have for friend URLs.

Fortunately, due to powerfull ISAPI support, there are already many powerful 3rd Party applications available which provides really good URL Rewrite support. I would like to mention two of these:
www.isapirewrite.com
www.urlrewriter.net

However, I recently needed to use the similar function on one of client website which is running on IIS 7, and before trying any of these 3rd Party tools, I decided to search and see if IIS 7.0 support and Viola! It does. The URL Rewrite module in IIS 7 is not only as powerful as you would expect it to be (supporting most of the Apache counterpart URL rewrite module), but its integration in the IIS Manager is a big plus. You can easily add and test rules them using the visual interface. Here is a very good beginner tutorial:
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

For some of the geeky fans, who still like the type this instead of wasting time in UI dialog, these rewrite rules are stored in your website web.config file, so you can view, add or edit these directly there too. Here is a sample of how these rules appear in the web.config file:

1
2
3
4
5
6
7
8
<rewrite>
	<rules>
		<rule name="Rewrite to article.aspx">
			<match url="^article/([0-9]+)/([_0-9a-z-]+)" />
			<action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" />
		</rule>
	</rules>
</rewrite>

You still have to type more than you have to do for something similar in Apache and other 3rd Party URL rewrite tools, but this is because of the XML syntax, and there price you have to pay for better (debatable) data format.

IIS 7 and Media Files 404.3 Error

Monday, August 13th, 2012

When working a new site content changes, we decided to add a new media files (of MP4) type. For playing this video file directly from the website, we decided to use the VideoJS Player.

Everything worked fine on the development machine (using IIS 6.0). However, when we deployed this to the Dev server machine using the IIS 7.5 and ASP.Net 2.0, we were getting the following server error when accesing the file:
HTTP Error 404.3 – Not Found

On server local machine, the detail of the error was:
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

So I know this has to do something with the file mapping. And sure enough, when I googled this, I found that in IIS 7.0 and 7.5, for the static content files, you need to define the supported types in the web.config. So, to make it all work, we just had to add the following in the web.config file:

1
2
3
<staticContent>
	<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
</staticContent>

This should go under the system.webServer tag.

I think it’s a nice security feature introduced by IIS 7.0, but having not used this before got me in a little trouble. Anyway, the lesson learned and documented.

HTTP URL Permanent Redirect

Saturday, May 29th, 2010

Recently, I migrated my website from the free domain syedgakbar.co.cc to my new domain www.syedgakbar.com. Once the migration process was done, I looked into options to redirect all the new traffic point to old site to my new site without breaking the links:

As I was hoping, it was just a one line change in the “.htaccess” file (this is supported in the Apache). Here is the exact code:

RewriteEngine On
RewriteRule (.*) http://www.syedgakbar.com/$1 [R=301,L]

RewriteEngine On

RewriteRule (.*) http://www.syedgakbar.com/$1 [R=301,L]

For those who are not familiar with RewriteRule syntax, the above line is very simple. It just tells the web-server to redirect all the requests (of all pages) to the new domain. The R=301 in the option tell the web-server that it’s a permanent redirect. This helps the search engine robots update their references too. This in most of the cases, help you retain your previous search engine ranking. This trick works for both the robots (search engine crawlers) and the persons viewing the site, and it’s seamless.

If you are running using Microsft IIS, then you can use a free ISAPI Rewrite utility:

http://www.isapirewrite.com/

Hope this helps.

RewriteEngine OnRewriteRule (.*) http://www.syedgakbar.com/$1 [R=301,L]

How to turn off Weak SSL Ciphers on IIS

Tuesday, April 7th, 2009

With growing security concersn for the site, it’s now recommended to don’t use the Weak or No Ciphers at all. Unfortunately, these weak ciphers are enabled by default in most of the IIS versions.

If you don’t want to supports the use of SSL ciphers that offer either weak encryption or no encryption at all, then you can easily turn them of by by modifying the corresponding registry entries under following path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\

Basically, to fix this security warning, you should disable the SSLv2 and any SSL Ciphers less than 128 bit encryption.

The following link discuss the steps you need to perform:
http://blog.techstacks.com/2008/10/iis-disabling-sslv2-and-weak-ciphers.html

If you want more info or details, please check the following link:
http://support.microsoft.com/kb/187498

As it’s risky task, I will recommend that you first try it on a test machine.

Good luck and be careful when editing registry entries.