Solved

Append http://www to a URL

Posted on 2016-08-03
4
65 Views
Last Modified: 2016-08-04
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
Comment
Question by:giveindia
4 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 41740614
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
 
LVL 35

Expert Comment

by:YZlat
ID: 41740913
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
 
LVL 27

Accepted Solution

by:
Dan McFadden earned 500 total points
ID: 41741031
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
 

Author Closing Comment

by:giveindia
ID: 41741931
That worked.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question