Nothing to see here, move on...
Sorry, couldn't resist. But I can totally get how this evolved from a habit that started by having the "
prefix to simplify the entry of URLs by removing the need to enter that common prefix.
If you get strict on anything in that way, it becomes harder to free yourself from your own restrictions. Even though the "
was never meant as restriction.
One "notice" comment I'll make to this:
A Browser will automatically extend an incomplete URL without www, so you did never need this.
Here's a screenshot of Chrome's Dev Tools, Network tab:
The network tab shows all requests the browser does. Starting with just tek-tips.com, neither prefixed by
http:// or
the browser makes its request to [ignore]
[/ignore]. You already get to the server, which redirects to http://
www.tek-tips.com, and then the server reacts with another redirect to http
s://[ignore]www.tek-tips.com[/ignore].
Depending on which Webserver software is used and how redirection rules are defined, this could also be done in one step. But never mind it takes tek-tips.com two steps to get there, tek-tips is not the only server doing such things automatically. Browsers also automatically follow redirects, so the user experience of it is an automatic fix of the URL address.
What will not work is starting with "tek-tips" without the ".com" TLD, because then Chrome (and most other browsers) will handle this as a search term and request a google search (or whatever you make your default search engine.
Well, and first of all in your usage of ShellExecute, "tek-tips" alone wouldn't even trigger opening the standard browser, but look for a file named "tek-tips". So before these 301 redirects happen, you'll need to ensure the ShellExecute addresses the default browser and interprets the cFileName parameter as a URL in the first place.
Regarding ShellExecute, the minimum requirement for it to interpret something as a URL is a www. prefix, but more to the point is a http:// prefix, that'll then find https:// automatically, unless a server is configured weirdly.
So what you could have done instead of the "
prefix is use the "
prefix to navigate to sites with/without
also with http or https.
You can't use the same strategy with a HttpRequest object, which would only return the status 301 and the redirect URL but won't automatically go there.
The conclusion is, you could change your code to:
Code:
cFileName = '[URL unfurl="true"]http://'[/URL] + Alltrim(Thisform.txtSldnTldn.Value)
That will a) open a browser and b) the browser will change to www. or not and to https:// or not automatically.
Chriss