Redirect with multiple mapped domains (htaccess and WordPress)

admin

Administrator
Staff member
We have a web portal for multiple countries. Each country has its own domain (i.e. countrydomain.com, countrydomain.de, countrydomain.it).
All of these country domains are mapped to our main domain (maindomain.org) with symlinks. The main domain holds the whole PHP code for the web portal. The .htaccess manages the redirections for all domains.

This works so far...

Now, I have to create a WordPress blog for each country which should be reachable under countrydomain.com/blog, countrydomain.de/blog an so on. Each country should have its own blog with its own content.

My problem is, that I can't create a "blog" directory for each country and just install Wordpress in this directory because of the mapping. I have only our maindomain.org.
I have tried to create directories named blog_com, blog_de, blog_it and redirect them with htaccess to the matching domain/blog, but with no success so far...

Is it best practice to create one wordpress-folder for each country? Which redirect rules do I need to manage the redirects? Or is there an even better solution?

Here comes a part of our htaccess to show you the current situation:

Code:
Options -Indexes
Options +FollowSymLinks

RewriteEngine on
RewriteBase /

# Enforce www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [QSA,R=301,L]

# Skip some directories
RewriteRule ^newsletter$ - [L]
RewriteRule ^newsletter/.*$ - [L]
RewriteRule ^cron/.*$ - [L]


# Rewrite main domain to main country domain (com)
RewriteCond %{HTTP_HOST} ^www\.maindomain\.org$ [NC]
RewriteRule ^(.*)$ http://www.countrydomain.com/$1 [QSA,R=301,L]

# Save current top level domain as environment variable
SetEnvIf Host ^www\.countrydomain\.com$ ENV_COUNTRYCODE=com
SetEnvIf Host ^www\.countrydomain\.de$ ENV_COUNTRYCODE=de
SetEnvIf Host ^www\.countrydomain\.it$ ENV_COUNTRYCODE=it

# SEO rewrite rules
RewriteRule ^/$ index.php [QSA,L]
RewriteRule ^$ index.php [QSA,L]
RewriteRule ^search$ index.php?status=19 [L]
RewriteRule ^myprofile$ index.php?status=50 [L]
RewriteRule ^myprofile/$ index.php?status=50 [L]
RewriteRule ^/?(xx)/([A-Za-z0-9ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ\%\+\_\-\/]{3,100}).html$ index.php?status=90&xxurl=$2 [L]
RewriteRule ^/?([A-Za-z0-9ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ\%\+\_\/\-]{3,300})/([0-9]+)(b|bw)$ index.php?status=25&id=$2&type=bw [QSA,L]
RewriteRule ^([0-9]+)(b|bw)$ index.php?status=25&id=$1&type=bw [QSA,L]
# ...