If I have a variational problem of the form:
$$\min \int_{a}^{b} F(x, y(x), y'(x)dx\quad\text{subject to}\quad \int_{a}^{b} G(x, y(x), y'(x))dx=C\tag{1}$$
The solution can be found by transforming the problem into an unconstrained problem:
$$\min \int_a^b H(x, y(x), y'(x), \lambda)dx\tag{2}$$
Where, $$H(x, y(x), y'(x), \lambda)=F(x, y(x), y'(x))-\lambda G(x, y(x), y'(x))\tag{3}$$
WHERE $\lambda$ is a Lagrange multiplier and solve then the Euler-Lagrange equation:
$$\frac{d}{dx}H_{y'}-H_y=0\tag{4}$$ together with the constraint.
Now, suppose my constraint becomes $$\int_{c}^{d} G(x, y(x), y'(x))dx=C\tag{5}$$ instead of $$\int_{a}^{b} G(x, y(x), y'(x))dx=C .\tag{6}$$ If $a\neq c$ or $b\neq d$ I cannot use the same trick, how can I solve the problem?
Hints:
Extend $F$, $G$, and $y$ in an arbitrary smooth fashion to the whole real $x$-axis $\mathbb{R}$. (Less is really needed; we are just illustrating the method.)
Replace the $H$-function in eq. (3) with $$\begin{align}H(x, y(x), y'(x), \lambda) ~=~&1_{[a,b]}(x)~ F(x, y(x), y'(x))\cr ~-~&\lambda~1_{[c,d]}(x)~G(x, y(x), y'(x)),\end{align}\tag{3'}$$ and replace eq. (2) with $$ \min_{y} \int_{\mathbb{R}} \!\mathrm{d}x~ H(x, y(x), y'(x), \lambda) \tag{2'}$$ with pertinent boundary conditions (BCs). Here $x\mapsto 1_{[a,b]}(x)$ denotes the indicator function for the interval $[a,b]$.