And when I submit the .htaccess file there is an error. The Page is not found and I am redirected to http://myotherwebsite/en/adifferentdirectory/directory2 . This makes no sense because the redirected URL and the destination URL are mixed.
This code works when there is just one directory :
Msg#: 4646801 posted 11:45 pm on Feb 19, 2014 (gmt 0)
The Page is not found and I am redirected to http://example.com/en/adifferentdirectory/directory2
I think you mean this the other way around: first you are redirected, and then you end up on a different page.
Are you quoting the rules exactly as they appear in htaccess? I would expect complications when one side ends in a directory slash and the other doesn't.
Fine-tooth-comb your htaccess. It sounds as if there is an earlier rule naming /directory1/ alone, which executes before the request ever gets a chance to see the longer rule. Always put specific rules before general ones, so a rule involving /directory1/directory2/ comes before anything naming /directory1/ alone.
Important! Does your htaccess file currently have any RewriteRules at all? If so, you need to change all rules using mod_alias (Redirect or RedirectMatch by that name) to RewriteRules, because mod_rewrite always executes before mod_alias in htaccess. Now do you see why the Forums rules insist on "example.com"? It can be example dot anything if you're discussing more than one domain.
directory3-what? When using RedirectMatch, you have to spell out the target using captures. Otherwise the target is taken as-is, with nothing reappended. If it's a real, physical directory, call it /directory3/ since that's its real name. Otherwise every redirect will be followed by a second redirect for the directory slash.
For the redirections that don't work, they bring me to a URL that is a mix of the directories of redirected URL and those of the destination URL.
That's why I suspected a rule-ordering problem. For example: