• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 87
  • Last Modified:

Append http://www to a URL

I would like to append http://www. either through code or in IIS. What is the best way of going about this ?

Thanks,
Aditya
0
giveindia
Asked:
giveindia
1 Solution
 
Paul MacDonaldDirector, Information SystemsCommented:
I'm guessing you mean prepend, not append; and the answer depends a lot on what it is you're trying to do.  The most basic answer would be something like...

Dim strNewURL as String = ""
strNewURL = "http://www." & strOldURL

...but it's hard to say without more information.
0
 
YZlatCommented:
Try checking whether the string starts with "http://www." first:

If Not strURL.StartsWith("http://www.", StringComparison.InvariantCulture) Then
	strURL = "http://www." & strURL

End if

Open in new window

0
 
Dan McFaddenSystems EngineerCommented:
I recommend using IIS URL Rewrite model.

Here's an article to explain how to do it.

Link:  http://weblogs.asp.net/owscott/iis-url-rewrite-rewriting-non-www-to-www

Dan
0
 
giveindiaAuthor Commented:
That worked.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now