0

I'm having troubles writing a seemingly easy RewriteRule/Condition:

example.com should redirect to example.com/de.
example.com/de shouldn't redirect.
example.com/en shouldn't redirect.
example.com/foobar should redirect to example.com/de/foobar.
example.com/de/foobar shouldn't redirect.
example.com/en/foobar shouldn't redirect.

What I have is this:

RewriteCond %{REQUEST_URI} !^\/(de|en)/(.*) [NC]
RewriteRule ^ http%{ENV:protossl}://%{HTTP_HOST}/de%{REQUEST_URI} [L,R=301]

But I always get too many redirects.

4

1 回答 1

1

Try:

RewriteRule ^(?!(de|en)) /de%{REQUEST_URI} [L,R=301]
于 2013-09-18T16:15:58.223 回答