On 30/01/2015 8:22 AM, "Mirko Hufnagel" <mirkohufnagel@xxxxxxxxx> wrote:
>
> Hello,
>
> My name is Mirko and I have a problem with our RewriteRules.
>
> What I want:
>
> Visitor type the URL www.linart.de
> And we forward him to www.linuxart.de/en
>
> That works!
>
> Visitor type the URL www.linart.de/en
> And we forward him to www.linuxart.de/en
>
> That works!
>
> Visitor type the URL www.linuxart.de/page1
> And we forward him to www.linuxart.de/en/page1
>
So is it linart.de/page1 or linuxart.de/page1 that needs to go to www.linuxart.de/en/page1 ??? I'll assume linart.de based on the below commented out example and take the above as typo.
> And that's the pain - I have no idear how we can solve that?! What I produce in my example below produce and endless loop of redirections.
>
> And idear?
> Any help would be great!
>
>
> # --------------
> RewriteCond %{HTTP_HOST} ^(www\.)?linart\.de$
> RewriteCond %{REQUEST_URI} ^/$
> RewriteRule ^/$ http://www.linuxart.de/en/ [R=307,NC,L]
>
> RewriteCond %{HTTP_HOST} ^(www\.)?linart\.de$
> RewriteCond %{REQUEST_URI} ^/en$
> RewriteRule ^/en$ http://www.linuxart.de/en/ [R=307,NC,L]
>
> #RewriteCond %{HTTP_HOST} ^(www\.)?linart\.de$
> #RewriteCond %{REQUEST_URI} ^/en/.+$
> #RewriteRule ^/en/(.*)$ http://www.linuxart.de/en/$1 [R=307,NC,L]
> # --------------
You need to rewrite only the requests that don't start with /en/ whereis in your example you are doing the oposite. Try this:
RewriteCond %{HTTP_HOST} ^(www\.)?linart\.de$
RewriteCond %{REQUEST_URI} !^/en/
RewriteRule ^/(.*)$ http://www.linuxart.de/en/$1 [R=307,NC,L]