问题
I have url like the follow: http://new2.silentdivers.com/links.php?lang=en
What will be the best way to do SEO freindly URL? Any help needed.
lang=en could be, lang=ge, lang=fr etc
回答1:
In my opinion the most important thing is that you need to understand that language should be only URL(and/or domain) based. Meaning URL I mean your script should always check only url and take decision what language is chosen. Many people misunderstand it and use cookies or sessions to check them and to choose language and it's a huge mistake for SEO.
There are 3 methods of making multilingual site. In my opinion and based on my experience as SEO expert any other won't be in fact SEO friendly
Method 1
domain.com
domain.com/lang2/
domain.com/lang3/
domain.comm/article
domain.com/lang2/article
domain.com/lang3/article
In this method you always check lang prefix after domain. If there is no prefix you display default language. It's the easiest method to implement and will work almost everywhere
Method 2
domain.com
domain.com/article
lang2.domain.com
lang2.domain.com/article
lang3.domain.com
lang3.domain.com/article
In this method you always need to check subdomain do determine language. Pros are that you can do SEO for subdomains (many directories don't accept domain.com/lang2/ but will accept lang2.domain.com )
Method 3
domain.com
domain.com/article
domainforlang2.com
domainforlang2.com/article
domainforlang3.com
domainforlang3.com/article
This method will be for bigger sites when you really need different domains. Disadvantage may be sometimes it's hard to find nice domain for each language
In above examples article can be anything but in fact this part should be also translated. So for example in method 1 for english language you can have domain.com/en/links/ and domain.com/pl/linki (linki is Polish translation for English word "links")
Also domain.com is only example. It can be domain.net , domain.org or any other domain.
You have to choose method on your own. For small sites method 1 and 2 are enough (2nd method for more SEO activities will be better)
EDIT
For method1 you can use this .htaccess :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)(.*)/?$ index.php
and in PHP you should simple check value of $_SERVER['REQUEST_URI']
In this case if it begins with lang2/ or lang3/ it means that's the selected language, otherwise default language is set.
来源:https://stackoverflow.com/questions/23463101/seo-friendly-url-how-to-best-way