Ronn0
Ronn0

Reputation: 2259

Htaccess redirect from subdir to Domain

I'm stuck with an htacces project. On my old domain i've: olddomain.eu/en/[uris] olddomain.eu/de/[uris]

Now i need to split the sites to different domains without losing the indexing so i created this htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteRule ^de(.*)$ http://www.domain.de/$1 [L,R=301]
    RewriteRule ^en(.*)$ http://www.domain.eu/$1 [L,R=301]
</IfModule>

The only problem is it now redirect like this: olddomain.eu/de/test.html to www.domein.de instead of www.domein.de/test.html

What am i doing wrong?

Upvotes: 1

Views: 51

Answers (1)

anubhava
anubhava

Reputation: 784918

Looks close but for correctness you can try this regex:

RewriteEngine On

RewriteRule ^de/(.*)$ http://www.domain.de/$1 [L,R=301,NC]
RewriteRule ^en/(.*)$ http://www.domain.eu/$1 [L,R=301,NC]

Upvotes: 2

Related Questions