SEO for PHP URLs?

风格不统一 提交于 2020-01-15 06:28:50

问题


I have many thousands of profile URLs that currently look like this:

view_profile.php?id=12345

Is there any SEO benefit for me to change them to something like:

member12345.htm

I can make the change in my .htaccess file but I'm curious if it's even needed?


回答1:


The easy solution edit your .htaccess file:

RewriteEngine On
RewriteBase /

RewriteRule ^member([0-9]+)\.htm(l)?$ view_profile.php?id=$1 [L,NC]
#or /member-1234.html
RewriteRule ^member\-([0-9]+)\-([^/])\.htm(l)?$ view_profile.php?id=$1 [L,NC]
#or /member-1234-user-name/
RewriteRule ^member\-([0-9]+)\-([^/]+)/?$ view_profile.php?id=$1 [L,NC]

L mean last rule, so if the regular expression is match, it will stop there.

NC mean non case so capital letters like ABC are treated the same as lowercase like abc.




回答2:


If you want these member pages to be found at Search Engines, it'd be good to do a change like this. But only moving the number around would help little , but not much.

To really get an effect, you need to put meaningful words in the URL, e.g. member-12345-max-weller.htm for my profile ;-)

This is because Google & Co. supposedly like static pages better than dynamic pages.




回答3:


Yes, query urls are not optimal for SEO.

But instead of .htaccess you should use a proper php url mapper.

Take a look at Silex, url mapping is one of its core features. Eg:

require_once __DIR__.'/silex.phar'; 

$app = new Silex\Application(); 

$app->get('/hello/{name}', function($name) use($app) { 
    return 'Hello '.$app->escape($name); 
}); 

$app->run(); 



回答4:


Yes there is requirement of static page url that is more effective for robots to understand the pages content. with url you have to also managed the title and description of page. rewrite the url with .htaccess file best better option.



来源:https://stackoverflow.com/questions/9133695/seo-for-php-urls

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!