[Tex/LaTex] How to avoid the “http:” part in hyperref’s \url

hyperrefurls

is it possible to use the \url command from the hyperref package with "shorthand" URLs, e.g.

\url{ipython.org}

instead of

\url{http://ipython.org} ?

It seems that the former would only link to local files on my computer, instead of retrieving the web address.
(I suppose I could be using \href, but \url is shorter and I'd like to keep its formatting features.)

Edit in response to karlkoeller's answer:

Sorry for not being sufficiently precise. I don't mind typing the 'http' part so much, but I'd rather not see it printed.

egreg's answer does what I want to do – many thanks!

Best Answer

It's better to use a different command, so that its usage is clear:

\documentclass{article}
\usepackage{xcolor}
\usepackage[
  colorlinks,
  linkcolor=magenta
]{hyperref}
\newcommand\rurl[1]{%
  \href{http://#1}{\nolinkurl{#1}}%
}

\begin{document}
This is a link \rurl{ipython.org} written in abbreviated form.
\end{document}

Of course you lose the tricks \url and \href are able to do with complex URI, for handling special characters, but short URI like this one should not have this problem.

The color in the image shows that it's indeed a link to a Web page.

enter image description here

Related Question