用於 SEO 目的的 Nodejs URL 修改 (Nodejs URL modifications for SEO purposes)


問題描述

用於 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 美觀且易於搜索引擎理解。我想要完成的最終結果是以下之一:

  1. yobyobi。com/ads/show/55c9ff9dcf68970612ba2d38/Sun‑Nov‑22‑2015‑8‑pm‑2007‑camry‑for‑sale
  2. yobyobi.com/ads/show/Sun‑Nov‑22‑2015‑ 8‑pm‑2007‑camry‑for‑sale/55c9ff9dcf68970612ba2d38
  3. yobyobi.com/ads/show/Sun‑Nov‑22‑2015‑8‑pm‑2007‑camry‑for‑sale/
  4. 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 user2610272user2610272)

參考文件

  1. Nodejs URL modifications for SEO purposes (CC BY‑SA 2.5/3.0/4.0)

#url #rewrite #node.js #SEO #routes






相關問題

正則表達式查找和替換 url 不起作用或如何使其起作用 (Regex to Find and Replace url does not work or how to make it work)

子網站的 URL 重寫? (URL Rewriting for a Subsite?)

使用 htaccess 從基本 URL 中刪除變量 (Remove variable from base URL with htaccess)

在 URL 地址中使用項目名稱而不是 ID (Using item's name in the URL address instead of IDs)

Perl Chèn chuỗi vào url tại các địa điểm cụ thể (Perl Inserting string into a url at specific places)

Cách ẩn mọi thứ sau tên trang web của bạn bằng .htaccess (How to hide everything after your webpage name with .htaccess)

在 gwt 框架中使用參數更改 url (Changing url with parameters in gwt framework)

用於 SEO 目的的 Nodejs URL 修改 (Nodejs URL modifications for SEO purposes)

將用戶重定向到外部站點 (Redirecting user to external site)

Python 循環遍歷 csv 文件中的 url 返回 \ufeffhttps:// (Python Looping through urls in csv file returns \ufeffhttps://)

主頁中的 React Router 目標 div id (React Router target div id in home page)

.htaccess https、www 和子域靜默重寫 (.htaccess https, www and subdomain silent rewrite)







留言討論