Continuous surjective function from closed interval to itself that fix only the endpoints I am trying to solve the following question

Does there exist a continuous function from $[a,b]$ to $[a,b]$ which is onto and $a$ and $b$ are the only two fixed points?

The function $f(x)= x$ has $a$ and $b$ as fixed points but it also has other fixed points.
When $a=0$ and $b=1$ the function $f(x) = x^2$ works. So I tried the function $f(x) = (x-a)(x-b) + x$ but in general I found that it does not work.
The function $f(x) = \log\left( \frac{e^b-e^a}{b-a}x+ \frac{be^a - ae^b}{b-a}\right)$ works for  several examples that I have checked but I am not able to prove in general.
Given points $a<b$,  I can imagine a function inside the rectangle of vertices at $(a,a), (a,b), (b,a), (b,b)$ such that the curve joins $(a,a)$ and $(b,b)$ and does not pass through any points of the form $(x,x)$ but I am not able to construct explicitly.  Hints are appreciated.
 A: You have already found the simple example $f(x)=x^2$ on the interval $[0,1]$. This example translates to every other interval $[a,b]$, where $a<b$. Simply take
$$g(x)=(b-a)\left(\frac{x-a}{b-a}\right)^2+a.$$
In general, if $f(x)$ is such a function on the interval $[0,1]$ then
$$g(x)=(b-a)f\left(\frac{x-a}{b-a}\right)+a,$$
is such a function on the interval $[a,b]$.
A: Let $a<c<b.$ Define $f$ to be the piecewise linear function that connects the points $(a,a),(c,b),$ and $(b,b).$
A: In general, any homeomorphism $g:[a,b] \to [0,1]$ induces the example $g^{-1}(g(x)^2)$ on $[a,b]$, and more generally, $g^{-1}(f(g(x)))$ for any example $f(x)$ on $[0,1]$.
Servaes' answer uses the bijection $g(x)=\frac{x-a}{b-a}$. This works because it is really a composition $[a,b] \to [0,b-a] \to [0,1]$.
Alternatively, one could instead do $[a,b] \to [1,b-a+1] \to [0,1]$ where the first function subtracts $a$ and adds $1$ and the second function takes the logarithm to base $b-a+1$.
So, $h(x)=(b-a+1)^{(\log_{b-a+1}(x-a+1))^2}+a-1$ (or more generally, $h(x)=(b-a+1)^{f(\log_{b-a+1}(x-a+1))}+a-1$) where $f(x)$ works on $[0,1]$) also works on $[a,b]$.
