Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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. See:

http://www.google.com/search?q=caroline+elisa

Until the plugin gets a fix, I am trying to use RedirectMatch to tell Google to index the root folder, not /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
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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)).

share|improve this answer
    
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! –  Caroline Elisa Aug 25 '12 at 14:40
    
Oh, yes, and I was using 302 as I was testing the outcome. –  Caroline Elisa Aug 25 '12 at 14:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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