Making PHP Pages dependent on GET parameters search engine friendly
Say there is an article on a site about sports "Kobe Bryant is the best"
1) Doe开发者_开发技巧s it make a difference to the google crawler, and for purposes of attaining a high search relevance whether that article is on this page:
a) www.sitename.com/sports.php?typeid=1&tid=3
OR on this one:
b) www.sitename.com/sports.php?type=basketball&topic=KobeBryant is the best
OR on this one
c) www.sitename.com/sports/basketball/KobeBryantisthebest
2) I am familiar with how to achieve (a) and (b) seems like a straightforward extension. How does one achieve a URL format like in (c)?
Thanks
You will need to create a .htaccess
file...
The code will have to be something like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^sports/([-a-z]+)*/([a-z-A-Z]+)*/$ ./sports.php?type=$1&topic=$2
This will rewrite the url so that is accessed by:
www.sitename.com/sports/basketball/KobeBryantisthebest
If you copy and paste the code it should just work as long as there is a page called sports.php and the PHP code will $_GET['type']
and wil $_GET['topic']
Hope this helps
For the first question, I think this one would be better:
www.sitename.com/sports/basketball/Kobe-Bryant-is-the-best
As question 2) has already been answered very well by swenflea, I will not deal with that anymore.
As for question 1): There clearly is a difference between a) and b)+c) with regards to search engine optimization (SEO), because in URL a) there are no keywords given that would match the given search query (instead there are IDs). As for b) and c) if somebody searches “basketball” Google would take your URL as a criterion for rating the website. In b) and c) it will find the word “basketball” in the URL and move your result a bit upwards in the SERPs, but in a) it cannot find “basketball”, so your URL won’t help you there.
There have also been researches on that humans prefer URLs which they can read, meaning that being able to choose between a URL redirecting to www.sitename1.com/sports.php?typeid=1&tid=3
and www.sitename2.com/sports/basketball/Kobe-Bryant-is-the-best
(cf. Kemal Fadillah), more people would choose sitename2. Yet, I have to admit, I do not know how many people really check the URL of a result ;)
When comparing b) and c) I do not know if there would be a difference for Google. You could hit problems with some crawlers if you turn the parameters around as there would be two different URLs:
www.sitename.com/sports.php?type=basketball&topic=KobeBryant is the best
www.sitename.com/sports.php?topic=KobeBryant is the best&type=basketball
I think Google does recognize them as the same site, but I do not know if they will give it the same rank as if you really only used one URL. In the past, people also talked a lot about that search engines do not rate the query part of a URI that high (query part = parts after ?
), but I think that one has been disclaimed by Google. Yet, there is again a psychological effect for humans, who like the URL without “cryptic” characters like ?
, &
and =
more.
So as for SEO you would remain with the problem that there might be multiple URLs for the same website when turning parameters around. As for humans you have the psychological effect.
Why c) is not perfect and Kemal Fadillahs solution is better is explained in the comment below Kemal Fadillahs answer.
精彩评论