• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

How do I remove the 'www' from the URL?

A

Andy-Free

Guest
Hi, I'm not sure if I'm in the right place to ask this..


I'm trying to create a URL rewrite rule that removes the www from the URL.

My web host is using Plesk (v9.5) on Windows 2008 (IIS 7 - I don't know if it's 7.0 or 7.5)

I can create a windows hosting rule that ADDS the www to a URL without it (e.g. http://example.com -> http://www.example.com), but I can't get the converse rule to work.

I have verified that the removal rule is correct by generating and testing it with the IIS 7 Rewrite Extension, which I found in Scott Guthrie's blog entry: http://weblogs.asp.net/scottgu/arch...problems-using-the-url-rewrite-extension.aspx

Here's the rule as I have it so far:

<system.webServer>
<rewrite>
<rules>
<rule name="remove www" stopProcessing="true">
<match url="(www.*)" />
<action type="Rewrite" url="http://example.com" />
</rule>
</rules>
</rewrite>
</system.webServer>

I've also tried the default rule that the IIS Rewrite Extension creates which removes any sub-domain prefix (e.g. http://blog.example.com -> http://example.com, but that doesn't work either - the URL doesn't get rewritten and the www remains.

I've asked my web host for assistance, but I thought I'd ask here as well :)
 
Hi Andy,

Did you have any luck with this?

Please explain how you force the WWW on the URL?

I have just changed from linux to windows server (Plesk 9.5.1) and need to have my http://site load as http://www.site

My .htaccess RewriteEngine On RewriteCond no longer works.

Many thanks!
Andy
 
For others looking, I have found out how to use mod_rewrite on a Windows Server.

http://www.iis.net/download/urlrewrite

Download the module on your server and automatically install it. Then go to your IIS7 control panel and under domain > IIS you should find the URL rewrite module. Open it and 'add rule' and there is a template for 'canonical domain name'

If you want to show http://domain.com add this to the primary host name, if you prefer http://www.domain.com, then add this to the primary host name.

HIH

http://learn.iis.net/page.aspx/664/using-url-rewrite-module-20/
 
Back
Top