1

I am using Transposh plugin to make my site bilingual. Unfortunately, despite having English as the default language and therefore available at example.com/xxx, Google is indexing example.com/en/xxx.

Until the plugin gets a fix, I am trying to use RedirectMatch to tell Google to index the root folder, not the /en/ subdirectory.

This is what I have in my .htaccess file in the site root directory, as well as in the .htaccess file in the /wordpress/ subdirectory where the WordPress installation is (as I am not sure where to put it!).

RedirectMatch 302 ^/en/$ /

Is this the correct method and syntax? It does not seem to be working.

FYI the complete .htaccess file in the root directory is:

# 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>

RedirectMatch 302 ^/en/$ /

# END WordPress

1 Answer 1

3

1) Why would you use RedirectMatch directive (from mod_alias) when you already have more powerful RewriteRule directives (mod_rewrite) in place? Why mix them up?

2) In any case -- your RedirectMatch rule will never be executed, since WordPress rules, the way how they done, will intercept all requests (unless, of course, if you really have /en/ folder).

You need:

  • convert rule to use RewriteRule instead of RedirectMatch (so it plays nicely with WordPress rules)
  • insert such rule somewhere before/on the top of WordPress rules

Something like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # your rule before WordPress rules
  RewriteRule ^en/(.*)$ /$1 [R=302,L]

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

I am using Transposh plugin to make my site 'bilingual'. Unfortunately, despite having English as the default language and therefore available at carolineelisa.com/xxx, Google is indexing carolineelisa.com/en/xxx.

BTW -- in such case using canonical URLs is very recommended option (one of the reasons why it was created): http://googlewebmastercentral.blogspot.co.uk/2009/02/specify-your-canonical.html

For example:

<link rel="canonical" href="http://carolineelisa.com/testimonials/" />

Another thing -- it's better to use 301 (Permanent Redirect) response code instead of 302 (Found) for such redirects (although 302 is better for testing as it is not cached by browsers + it allows easier "recovery" in case something goes wrong (e.g. redirecting to a wrong place etc etc)).

2
  • Thank you LazyOne. The reason I was trying to use RedirectMatch is that I didn't really know what I was doing! I appreciate your in depth answer and I will now look into canonical URLs. Cheers! Aug 25, 2012 at 14:40
  • Oh, yes, and I was using 302 as I was testing the outcome. Aug 25, 2012 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.