Go Back   Singapore Web Hosting Talk > LEARNING CENTER > End User

End User For the end user. For people who use web hosting accounts.

Reply
 
Thread Tools
Old 22-04-2010, 16:36   #1
stevie
SGWHT Newbie
 
Join Date: 05-11-2009
Location: Malaysia
Posts: 99
stevie is on a distinguished road
How to force my domain with www entry

You might ask how to force my domain name with www.

Example:
my domain name: domain.com
I want when public browse, it should go to http://www.domain.com

Resolution:
With cPanel(Linux Hosting Plan), HELM3 & 4(Windows Server 2003 server)

you may use the following code and replace the domain.com to your domain name to your .htaccess file from public_html(Linux) folder or wwwroot(Windows) folder.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
With DotNetPanel(Windows Server 2008 server)

you may use the following code and replace the domain.com to your domain name to your web.config file from wwwroot folder.
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^domain.com" ignoreCase="false" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite
For Helm Control Panel (Windows Server 2003 server),

You may add the code as below to global.asax from wwwroot folder.

protected void Application_BeginRequest( object sender, EventArgs e)
{
//check the request to make it starts with www
//and is not localhost (dev)
if (!Request.Url.Host.StartsWith("www") && !Request.Url.IsLoopback)
{
//no ... redirect.
UriBuilder builder = new UriBuilder(Request.Url);
builder.Host = "www." + Request.Url.Host;
Response.Redirect(builder.ToString(), true);
}
}
__________________
Hosting Services = Hosting features + Customer Services + Technical Support
Linux hosting, Windows hosting, Email hosting, Semi dedicated server, dedicated server, VPS
********.sg | ********.in | ********.com
stevie is offline   Reply With Quote

Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump




All times are GMT +8. The time now is 23:36.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright (C) 2002-2015 Brought to you by Singapore Web Hosting Talk (SGWHT). All Rights Reserved.