Given this directory structure:
.
├── assets
│ └── img/
│ └── foo.png
├── en
│ └── index.php
└── fr
└── index.php
There are two domains:
english.com
french.com
My goal is to redirect
english.com => english.com/en
french.com => french.com/fr
english.com/fr => french.com/fr
french.com/en => english.com/en
no redirects for:
english.com/assets/img/foo.png
french.com/assets/img/foo.png
The current solution is not working propery how to achieve the goals above
<IfModule mod_rewrite.c>
RewriteEngine On
# no www, https only
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTP_HOST} ^www\.%{HTTP_HOST}$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^(en) - [L]
RewriteRule ^(fr) - [L]
RewriteRule ^(assets) - [L]
redirectMatch 301 ^/en$ https://english.com/en
redirectMatch 301 ^/fr$ https://french.com/fr
RewriteCond %{HTTP_HOST}: englisch.com$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/en/$1 [R=301,L]
RewriteCond %{HTTP_HOST} french.com$ [NC]
RewriteRule ^(.*)$ https://french.com/fr/$1 [R=301,L]
</IfModule>