Published on: 03 August, 2016

How to redirect www to non www using URL Rewriter in Windows IIS

Posted by andy | 1355 views 0 likes 1 favourites 0 comments
Tumblr Digg Google Plus

One of the best plugin you can use to perform a redirection in Windows IIS is by installing url rewriter component. Once it has been installed you can easily copy the following code into your web.config file.

Many people wonders which one is actually redirecting www to non www or the other way around. My preference is definitely www to non www because it is shorter and less typing. If you see many of the popular site like facebook or twitter, they all use the shorter url address version.

Here is the code to perform a redirection from www to non www. Remember that you place the rewrite rules inside the system.webServer config section.

<system.webServer>
<rewrite>
	<rules>
		<rule name="Redirect to non-www" stopProcessing="true">
			<match url="(.*)" negate="false"></match>
			<action type="Redirect" url="http://bytutorial.com/{R:1}"></action>
			<conditions>
				<add input="{HTTP_HOST}" pattern="^bytutorial\.com$" negate="true"></add>
			</conditions>
		</rule>
	</rules>
</rewrite>
</system.webServer>
Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.
Related Articles
Published on: 23 August, 2016
When you try to run MVC site or ASP.Net framework 4 website, if you receive the following error: HTTP Error 500.21 - Internal Server Error. Saying Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list. It means the ASP.Net has not been properly registered on your IIS.
Published on: 18 March, 2016
If you have a VPS or a dedicated server and the DNS Server is available, you must take a precaution on protecting your DNS server from DOS(Denial of Service) or DDOS(Distributed Denial of Service) Attack. The attacks can be done by sending huge fake volume queries to your DNS server so it can cause performance degradation on your server. To overcome this problem, you can do the following actions on your server
Published on: 19 February, 2016
In order to allow loading and downloading json file on your site, you have to add json extension in mime type and handler mappings in IIS windows server. By default this extension is not view-able. Therefore you will need manually mapping json extension into your IIS. To do this, you must have to get an access to your IIS, if you do not have, please request your site administrator to add this extension for you. For users host their sites on GoDaddy or other web hosting providers will need to contact their hosting provider.