Redirect WordPress Sub Folder to a Sub Domain

I have a site that is actually a multisite using subdomains and I would like to remap the subfolder translations to a sub domain.

domain.com (main site)
blog.domain.com (mu site for the blog)

With WPML, I have:

Read More
domain.com/fr/ (for the French translation)
blog.domain.com/fr/ (for the French translation)

I would like to have the following:

domain.com/fr/ --> fr.domain.com
blog.domain.com/fr/ --> blogue.domain.com

I think this could be possible with Rewrite rules, but I can’t get it to work properly.

Here is the current default WordPress MU .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]

Many thanks for your help!

Related posts

Leave a Reply

2 comments

  1. Keep your .htaccess like this:

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
    RewriteRule ^fr/(.*)$ http://fr.domain.com/$1 [NC,R=302,L]
    
    RewriteCond %{HTTP_HOST} ^blog.domain.com$ [NC]
    RewriteRule ^fr/(.*)$ http://blogue.domain.com/$1 [NC,R=302,L]
    
    RewriteRule ^index.php$ - [L]
    
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    
    RewriteRule ^(.+?.php)$ $1 [L]
    
    RewriteRule . index.php [L]
    
  2. You can add to .htaccess:

    RewriteCond %{HTTP_HOST} ^domain.com
    RewriteRule ^/fr/ http://fr.domain.com/fr/ [R,L]
    
    RewriteCond %{HTTP_HOST} ^blog.domain.com
    RewriteRule ^/fr/ http://blogue.domain.com/fr/ [R,L]