# Why does \let\oldindex not work in this code?

This is a follow-up question to: How to make indexed words clickable in the text?

I'm having two problems with the code given by @Stephen.

1. If I use the following code to redefine the \index command, the link to the entry in the Index, will not work with xindy

‎\let\oldindex\index‎‎
\renewcommand*{\index}[1]{\oldindex{#1@\protect‎\hypertarget{#1.ind}{}#1}\href{\#‌​#1.‎ind}{#1}}‎

2. My index entries with subentries (e.g. \index{foo!bar}) could not be used this way.

BTW, my document is in Persian which is an RTL language.

Edit:
Here is the code which I'm having problem with it:

\documentclass{article}
\usepackage{makeidx}
\makeindex
\usepackage{hyperref}

\let\oldindex\index
\renewcommand*{\index}[1]{\oldindex{#1@\protect\hypertarget{#1.ind}{}#1}\href{\#‌​#1.ind}{#1}}

\begin{document}
test \index{test}% problem 1
\index{foo!bar}% problem 2

\printindex
\end{document}

-
Most likely you need to use \LetLtxMacro, instead of \let. A detailed description of \LetLtxMacro can be found at this question at closed square root symbol. –  Peter Grill Nov 10 '12 at 21:41
Please make a MWE with all the code necessary to show how this "doesn't work". –  egreg Nov 10 '12 at 22:32
@egreg: I added a MWE to my post. –  Vahid Damanafshan Nov 11 '12 at 6:03
The problem is that \subsubitem is written inside the argument of \hypertarget. Probably Xindy gets confused by the two ! it finds in the same entry. –  egreg Nov 11 '12 at 10:31
@egreg: Isn't there a solution to this problem? –  Vahid Damanafshan Nov 11 '12 at 18:49