Mobile app version of vmapp.org
Login or Join
Mendez628

: SEO on multilanguage website URL I'm setting up a multilanguage website and I would like to have your help to take the best decision as regard SEO. After reading this. I would like to change

@Mendez628

Posted in: #Geolocation #Htaccess #Language #ModRewrite #Seo

I'm setting up a multilanguage website and I would like to have your help to take the best decision as regard SEO. After reading this.

I would like to change my URLs from this form mywebsite.com/page?lang=es to mywebsite.com/es/page?lang=es. I need to keep the ?lang=es for other things.

My .htaccess file already contains these things (to remove .php extension of page.php).

RewriteCond %{THE_REQUEST} ^GETs.+.php [NC]
RewriteRule ^(.+).php$ / [NE,R=301,L,NC]

RewriteCond %{REQUEST_URI} !.php$ [NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule . %{REQUEST_URI}.php [PT]

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Mendez628

2 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

This isn't really an answer to the question, but you may want to bear in mind that Google's guidelines says to avoid using URLs with parameter strings in, for languages or other wise.

So If your making the effort of tidying up your URLs you might as well follow best practices.

Google Guidlines URL structure

Google Guidlines Multilingual sites and URL structure

10% popularity Vote Up Vote Down


 

@LarsenBagley505

Something like this will work.

RewriteCond %{QUERY_STRING} ^(lang=es)$
RewriteRule ^$ /es/page.php?lang=es
RewriteRule ^index.php$ /es/page.php?lang=es


Since you can't match against a query string inside a rewrite rule we utilize %{QUERY_STRING}. If you use a relative path, as in the example, you will get a silent redirect (eg. the URL will not change, but apache will serve the new page). If you want a 301 redirect you will have to use the full FQDN URL including the protocol, such as www.example.com/es/page.php?lang=es.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme