: RedirectMatch in .htaccess not working 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,
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
More posts by @Gail5422790
1 Comments
Sorted by latest first Latest Oldest Best
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/(.*)$ / [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): 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)).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.