Shortest path in a graph where edges are forbidden depending on the path taken
The decision version of the problem you describe seems to be coNP-complete (assuming that the weight function description is polynomial in the size of the description of the graph).

The language corresponding to the decision version would be $L=\{G,w,s,t,p : p  \text{ is the shortest path in G between s and t according to } w\}$

Lets take the complement of the language Hamilton Cycle, denoted by
 $\overline{HC}=\{G\big| \text{There is no hamiltonian cycle in G}\}$ (hamiltonian cycle is a cycle that visit every vertex of G exactly once).

It is well known that $\overline{HC}$ is coNP-complete.

Now we can reduce $\overline{HC}$ to $L$ (in polynomial time):

On input graph $G$:


Take an arbitrary vertex $u$, split it into two $u_{start}$,
$u_{end}$ and connect them to all neighbors of $u$.
Create a weight function w in which all edges connected to $u_{end}$ has
$\infty$ weight unless the path we have followed visits each vertex
in $V \setminus \{u_{end}\}$ exactly once, and all other edges has weight 1
(this condition can be checked by a "short code" therefore $|w|$ is
polynomial).
Add an edge $e'$ between $u_{start}$ and $u_{end}$ with a constant weight of $n+1$.
Output $(G,w,u_{start},u_{end},p)$ where $p$ is the path $u_{start} \underset{e'}{-}v_{end}$


The reduction is polynomial, and observe that there is no Hamiltonian cycle in $G$ if and only if $u_{start} \underset{e'}{-}v_{end}$ is the shortest path in $G$ between $u_{start}$ and $u_{end}$.

So there is no polynomial algorithm for your problem (unless P=NP).