我对 SEO - PHP 有疑问。
我有 2 个页面:新闻列表页面和新闻详细信息页面。
但是,从 SEO 的角度来看,如何区分 URL 中的这两个页面?
目前,我正在使用这些 URL:
- www.site.com/it/news/page-1/- www.site.com/it/news/page-2/... (带分页的新闻列表)
- www.site.com/it/news/title-news-detail/ (新闻详情)
我的文件.htaccess代码:
# first parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ index.php?lang=$1 [L]
#
# second parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/$ index.php?lang=$1&page=$2 [L]
#
# third parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ index.php?lang=$1&page=$2¶m=$3 [L]
我的问题是读取第三个参数,因为我不知道这是页码还是新闻标题..
最佳答案
像这样:
# ignore files and directories from all rules below
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# first parameter
RewriteRule ^([^/]+)/$ index.php?lang=$1 [L,QSA]
# second parameter with pagination
RewriteRule ^([^/]+)/page-(\d+)/$ index.php?lang=$1&page=$2 [L,QSA]
# second parameter with title
RewriteRule ^([^/]+)/([^/]+)/$ index.php?lang=$1&title=$2 [L,QSA]
# third parameter
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ index.php?lang=$1&page=$2¶m=$3 [L,QSA]
关于php - (SEO + htaccess) 带有分页和页面详细信息的页面列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33809811/