How to do Feature Scaling for these ranges [0,1] and [-1,1]?
What you said is right, the above equation is for normalizing the data with-in the range of [0,1]

Now, we can generalize using the below equation 

To normalize in $[-1,1]$ you can use:

$$
x'' = 2\frac{x - \min{x}}{\max{x} - \min{x}} - 1
$$ 

In general, you can always get a new variable $x'''$ in $[a,b]$:

$$
x''' = (b-a)\frac{x - \min{x}}{\max{x} - \min{x}} + a
$$