homepage Welcome to WebmasterWorld Guest from 184.73.104.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
http://example.com to http://www.example.com/
ashis06

5+ Year Member



 
Msg#: 3754340 posted 11:05 am on Sep 29, 2008 (gmt 0)

Hi,

I have one simple static html website, which i want redirect my domain to www prefix.
http://example.com to http://www.example.com/

Kindly suggest what is the solution? I tried with .htaccess file but it's not working. I think it's hosted in window server.

Is there any option or tools to know on whcih server a site is hosted ?

[edited by: engine at 11:20 am (utc) on Sep. 29, 2008]
[edit reason] Please use example.com [/edit]

 

mrMister

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3754340 posted 4:03 pm on Sep 29, 2008 (gmt 0)

Netcraft [netcraft.com] will tell you what web server software your site is running.

woop01

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3754340 posted 4:35 pm on Sep 29, 2008 (gmt 0)

Do you have root access?

docluv

10+ Year Member



 
Msg#: 3754340 posted 9:54 pm on Oct 17, 2008 (gmt 0)

Here is an custom .NET httpModule that will do what you want.

Imports Microsoft.VisualBasic
Imports System.IO
Imports TheBeerHouse.BLL
Imports System.Web
Imports System.Text.RegularExpressions

Public Class URLRewrite
Implements IHttpModule

Private Shared wwwRegex As New Regex("https?://www\.", RegexOptions.IgnoreCase Or RegexOptions.Compiled)
' Private Shared nonwwwRegex As New Regex("https?://", RegexOptions.IgnoreCase Or RegexOptions.Compiled)

Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

End Sub

Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
AddHandler context.BeginRequest, AddressOf BeginRequest
End Sub

Private Sub BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
Dim app As HttpApplication = CType(sender, HttpApplication)
Dim Request As HttpRequest = app.Request
Dim Response As HttpResponse = app.Response

Dim sRequestedURL As String = Request.Url.ToString.ToLower

Dim bWWW As Boolean = wwwRegex.IsMatch(sRequestedURL)
Dim redirectURL As String = String.Empty
If bWWW Then
redirectURL = wwwRegex.Replace(sRequestedURL, String.Format("{0}://", Request.Url.Scheme))
Do301Redirect(Response, redirectURL)
End If

End Sub

Private Sub Do301Redirect(ByVal Response As HttpResponse, ByVal redirectURL As String)

Response.RedirectLocation = redirectURL
Response.StatusCode = 301
Response.End()

End Sub

End Class

ashis06

5+ Year Member



 
Msg#: 3754340 posted 9:18 am on Feb 4, 2009 (gmt 0)

ok.. thanks docluv !

But where it should be included ? Is it for all of my webpages or only home page ?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved