nileshparmar
07-19-2010, 06:29 AM
hi,
i want to set www redirection
if anybody type
http://example.com it should redirect to http://www.example.com
I had googled lot but i could not found any solutions so please guys help me to resolve this issue
We are using
Windows 2008 R2 Standard 64 Bit & Plesk Panel 9.5
Softsys Hosting
07-19-2010, 08:21 AM
You can write below code in Global.asax file and this should help:
protected void Application_BeginRequest( object sender, EventArgs e){
if (!Request.Url.Host.StartsWith( "www" ) && !Request.Url.IsLoopback)
{
UriBuilder builder = new UriBuilder (Request.Url);
builder.Host = "www." + Request.Url.Host;
Response.Redirect(builder.ToString(), true );
}
}
SI_Support
07-19-2010, 12:36 PM
Hello!
I think this post should help:
http://www.trainsignaltraining.com/windows-server-2008-http-redirection/2008-03-27/
PremiumHost
07-19-2010, 09:52 PM
I think this post should help:
trainsignaltraining.com/windows-server-2008-http-redirection/2008-03-27/
The instruction is permanent redirect to a different domain.
The OP wants redirect from yourdomain.com to www.yourdomain.com
On IIS, URL Rewrite can be used to do such thing.
Hopefully this helps: http://www.webhostingtalk.com/showpost.php?p=4348088&postcount=6
kpmedia
07-20-2010, 02:33 AM
Use Ape with htaccess - http://www.helicontech.com/ape/
Then use this in a .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
I personally despise the coding for redirects in IIS7, and prefer the easier htaccess use.
I do like IIS7, however.
nileshparmar
07-20-2010, 06:10 AM
Use Ape with htaccess - http://www.helicontech.com/ape/
Then use this in a .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
I personally despise the coding for redirects in IIS7, and prefer the easier htaccess use.
I do like IIS7, however.
As far as i know ,.htaccess file use for Linux server only, however, please tell where to put .htaccess files i meant to say on which path ?
inside httpdocs folder ?
nileshparmar
07-20-2010, 08:35 AM
Use Ape with htaccess - http://www.helicontech.com/ape/
Then use this in a .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
I personally despise the coding for redirects in IIS7, and prefer the easier htaccess use.
I do like IIS7, however.
I confirmed, The above code is not working on window server, & it is working only on Linux server.
Nilesh