Link to home
Start Free TrialLog in
Avatar of giveindia
giveindia

asked on

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
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

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.
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

ASKER CERTIFIED SOLUTION
Avatar of Dan McFadden
Dan McFadden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of giveindia
giveindia

ASKER

That worked.