简体   繁体   中英

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?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM