問題描述
用於 SEO 目的的 Nodejs URL 修改 (Nodejs URL modifications for SEO purposes)
我有一個基於 Nodejs + Drywall + Openshift 的工作應用程序,抱歉它是阿拉伯語的。基本上,我希望改進服務,但有一個主要障礙。該網站是分類網站,我需要針對 SEO 對其進行優化,但是,我的廣告鏈接顯示如下...
http://yobyobi.com/ads/show/55c9ff9dcf68970612ba2d38
55c9ff9dcf68970612ba2d38 是我的 mongoDB 上的廣告 ID,我也有記錄Add 的指示日期和標題結合“Sun‑Nov‑22‑2015‑8‑pm‑2007‑camry‑for‑sale”,目的是使 URL 美觀且易於搜索引擎理解。我想要完成的最終結果是以下之一:
- yobyobi。com/ads/show/55c9ff9dcf68970612ba2d38/Sun‑Nov‑22‑2015‑8‑pm‑2007‑camry‑for‑sale
- yobyobi.com/ads/show/Sun‑Nov‑22‑2015‑ 8‑pm‑2007‑camry‑for‑sale/55c9ff9dcf68970612ba2d38
- yobyobi.com/ads/show/Sun‑Nov‑22‑2015‑8‑pm‑2007‑camry‑for‑sale/ li>
現在,選項 3 是理想的,但如果我必須按廣告標題而不是廣告 ID 進行搜索,我的應用程序會變慢。類似於 Stackoverflow 正在做的事情(附圖)
Stackoverflow 示例
代碼
app.get('/ads/show/:id', require('./views/account/ads/index').read);
上面的行為我返回了包含所有詳細信息的廣告,包括我想要使用的標題,但問題是我在收到標題後無法更改路由 URL。
我不確定是否這個模塊將有助於我嘗試做的任何事情,它被稱為“命名路由”
有人遇到過這個問題嗎?如果是這樣,您能否分享一些關於如何最好地解決問題的見解?
提前致謝,
參考解法
方法 1:
well, the solution was dead simple, do the following:
add * as a wild card like this
app.get('/ads/show/:id/*', require('./views/account/ads/index').read);
now when you create the links to the post, attach anything where the * is and it should show the same Ad without breaking the page.
Cheers
(by user2610272、user2610272)