本帖最後由 amnoob 於 2014-1-24 22:03 編輯 # d7 S- O& X0 n
咚咚來了 發表於 2014-1-24 19:08 ) Z# K/ n8 ]0 G [+ W' ?
1. 第一個問題( {7 K- `, }( I t( F9 R
你舉例說的別人的網站,有可能後面那個就是id, 這也是很常見的一種做法,特別是中文cms, ... 6 ^* S$ D p$ B8 l2 _
非常非常感謝兄台的再次耐心回復!
/ K2 z' [, D) p' P( a* u7 b! x6 ]# g* P# }, V
我完全是php新手,然後我看著程序裡面的其它代碼並再三google,學著自己寫了個function(由product id提取product name再生成url格式);由於真的是完全新手,由product name生成url弄「ereg_replace」這個地方又折騰了我幾個小時,汗,我發誓一定要抽時間好好學學php。1 D# A1 t: Q c$ N, W; V1 L/ a9 S4 Z
0 ?$ r0 L- h% b5 Q現在我在"_header.tpl"文件<head>裡面加入下面代碼- 2 q5 a4 I' V" }
- {if $detailed}
8 U8 r% ]! ]' X- }! R - <link rel="canonical" href="{$setting.site_url}/{$product.id}/{if getProductNameAndFormatForUrl($product.id)}{/if}.html">
# D, A; \ w$ ^* O9 |) R$ o0 I! x% V- h - <link rel="shortlink" href="{$setting.site_url}/product-details.php?id={$product.id}">
2 B# g; _5 N9 U5 p% u# \( R8 f - {/if}& U; |2 H% ]# |) l) A/ s* f$ l
複製代碼 已經成功實現在產品頁面輸出- % \, x& |( C5 A1 e: `
- <link rel="canonical" href="http://www.mydomain.com/1392/tao-of-badass.html">* w4 q! s- X7 d# u* U% R
- <link rel="shortlink" href="http://www.mydomain.com/product-details.php?id=1392">1 s8 g# c5 M, o# B2 r2 d% e
複製代碼 我詳細查看了,所有產品頁面都成功了;這樣之後是代表以後google只收錄一次並且只收錄帶"canonical"標籤的url了嗎?並且會將已經用原始url收錄了的頁面慢慢更新為帶"canonical"標籤的那個url?
( Q; p# p! u. f5 Q! t5 @) K, o9 p5 ~3 U, ?$ E# T: W( L* ]
5 f5 N- y4 o% Q3 Z: w& j' o' G9 J: [+ A# t( ]1 {5 r3 E/ N
& a" F% p$ z1 A p* I+ Z |