【发布时间】:2011-12-27 18:51:21
【问题描述】:
我需要帮助我为我的网站重写 htaccess URL。
问题是,只有某个类别的第一页有漂亮的免费 URL,而所有其他页面都有脏 URL。
例如第一页有这样的链接:
http://www.my-site-name.com/Category-name/Subcategory-name/
但是第 2 页,以及任何其他页面都是这样的:
http://www.my-site-name.com/showcat.php?cat=Category-name&subcat=Subcategory-name&page=2
http://www.my-site-name.com/showcat.php?cat=Category-name&subcat=Subcategory-name&page=3
所以,我需要一些 SEO 友好的 htaccess 重定向规则来制作这样的 URL:
http://www.my-site-name.com/Category-name/Subcategory-name-page-X/
或者像这样
http://www.my-site-name.com/Category-name/Subcategory-name/X/
但可能我更想先。
这是 .htaccess 的一部分:(我刚刚添加了完整内容,也许还有更多内容。
## For top rated items
RewriteRule ^top/page/(.*)/$ top.php?page=$1 [L]
## For latest items
RewriteRule ^latest/recent-page-(.*)/$ latest.php?page=$1 [L]
## For show most rated - most clicked - most downloaded and most searched items
RewriteRule ^most-rated.html$ showmost.php?type=1 [L]
RewriteRule ^most-clicked.html$ showmost.php?type=2 [L]
RewriteRule ^most-downloaded.html$ showmost.php?type=3 [L]
RewriteRule ^most-Searched.html$ showmost.php?type=4 [L]
## For showing category of item
RewriteRule ^(.*)/$ showcat.php?cat=$1 [L]
## For showing subcategory of item
RewriteRule ^(.*)/(.*)/$ showcat.php?cat=$1&subcat=$2 [L]
## For showig item
RewriteRule ^(.*)/(.*)/(.*).html$ show.php?cat=$1&sub_cat=$2&img=$3&rewrite=true [L]
## this section should be inserted just after the showing item rule above
#if the query string has cat, sub_cat and Img
RewriteCond %{QUERY_STRING} ^cat=(.+)&sub_cat=(.+)&img=(.+)$ [NC]
#and it is for resource show.php, then 301 redirect to Keyword rich URL
RewriteRule ^show\.php$ http://www.my-site-name.com/%1/%2/%3.html? [NC,L,R=301]
【问题讨论】:
-
我是新手。请告诉我如何才能接受正确答案,我该怎么办?
-
答案左侧有一个灰色复选标记。只需点击回答您问题的问题旁边的问题(最佳)。