0

I have a folder structure, like this:

  • forum
    • .htaccess
    • [some more files]
  • forum_english
    • .htaccess
    • [some more files]

forum/.htaccess looks like this:

RewriteEngine on

RewriteCond %{HTTP_HOST} \.(com|net)$ [NC] # just rewrite if the query comes from an english languaged domain
RewriteRule ^(.*)$ ../forum_english/$1

#some more RewriteRules from another forum. I don't know, if I am allowed to show them. They should work well, side by side.

forum_english/.htaccess is the default MyBB-htaccess-File.

Sadly this causes an infinite loop. To prevent this, I have to insert a [L]-Flag which skips the forum_english/.htaccess-file (but the rules in this file should be executed, too!). I also tried the [N=2]-Flag instead ... but still infinite loop.

I use Apache 2.2.17 and have no access to error_logs or the files in /etc/apache2/sites-enabled/.

Any ideas what I did wrong?

masegaloeh
  • 18,498

1 Answers1

1

If the user arrives via .com or .net, they would presumably continue to do so after you've rewritten the request to a relative location as shown in your example. In other words, the HTTP_HOST condition will always be true.

The .* regular expression is equivalent to "match (almost) any character 0 or more times," and the ^ (start of string) and $ (end of string) markers won't do anything special for you here, since everything between is matched. Because the pattern will effectively match any string, the resulting path after a rewrite to ../forum_english will match as well.

Essentially, the redirect loop occurs because you guarantee both conditions to always be true.

I think you should do some thinking about the definite conditions that indicate that a rewrite needs to occur. What patterns will occur before (but not after) the user has been redirected? Once you have those conditions figured out, then you can investigate how to create the appropriate mod_rewrite rules.