wordpress.htaccesshttp-status-code-404qtranslate-x

.htaccess redirect from subdomain to main in WordPress


I'm trying to add languages to my wordpress website. For this I'm using "qTranslate X" plugin in "per domain" mode.

It should work as follows:

http://domain.com - main language
http://en.domain.com - english
etc...

What I need is to redirect all requests from subdomain to main domain. The rest will be done by the plugin.

Example:
http://en.domain.com/category/article
should be redirected to
http://domain.com/category/article

I modified main .htaccess WP file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^en\.domain\.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

But, unfortunately, it works only for the home page (i.e. http://en.domain.com). When I type http://en.domain.com/category/article I see 404 Not Found page.

Thanks for any help!


Solution

  • I've spent a lot of hours googling and, finally, found an answer. I want to remind, that my problem was to adjust "qTranslate X" plugin to serve my multilingual website. So here's what I did to achieve this.

    In Settings -> Permalinks I have "custom structure" checked, http://domain.com/%category%/%postname%

    In qTranslate -> "Advanced Settings" -> URL Modification Mode: Use Per-Domain mode. I set "domain.com" for main language, "en.domain.com" - english etc.

    You don't have to change default WordPress .htaccess code for permalinks custom structure, it perfectly works with "qTranslate X" plugin. So make sure your .htaccess file looks like this.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    

    The only thing, that needs to be done, is to make sure, that requests to subdomain are processed as requests to the main domain. I.e. your subdomain folders must point to the folder, where WordPress is installed. On different hostings it may be achieved by different ways. As for me, in the domain settings I've found an option "process all requests from subdomains, that don't exist". So I didn't even have to create any subdomains at all! Just a single chechbox. If you are not sure, how to do this, contact your hosting support service and ask them to help.