我正在使用urlrewriting.net作爲我的urlrewriting。我需要一些正則表達式的幫助(我仍然沒有得到....)。另一個正則表達式 - 如何識別查詢字符串
我想匹配
www.mysite.com/restaurant
- >匹配,並返回 「restaurant
」www.mysite.com/restaurant?page=1
- >匹配和 回報 「restaurant
」www.mysite.com/restaurant?[SOME_RANDOM_QUERYSTRING]
- >匹配 並返回「restaurant
「www.mysite.com/seattle/restaurant
- >匹配並返回」seattle
「和 」restaurant
「www.mysite.com/seattle/restaurant?page=1
- >匹配和 回報」seattle
「和」restaurant
「www.mysite.com/seattle/restaurant?[SOME_RANDOM_QUERYSTRING]
- >匹配 並返回」seattle
「和」restaurant
「www.mysite.com/seattle/restaurant-michelangelo
- >不趕上www.mysite.com/seattle/restaurant/sushi
- >匹配,並返回 「seattle
」 和 「restaurant
」 和 「sushi
」www.mysite.com/seattle/restaurant/sushi?page=1
- >匹配,並返回 「seattle
」 和 「restaurant
」 和 「sushi
」www.mysite.com/seattle/restaurant/sushi?[SOME_RANDOM_QUERYSTRING]
- > 匹配,並返回 「seattle
」 和 「restaurant
」 和 「sushi
」www.mysite.com/seattle/restaurant-michelangelo
- >不趕上
點是我需要url的目錄部分,而不是查詢字符串部分。問題是,我可以從我的網絡分析工具看到,人們用兩個詞搜索。他們都搜索城市(西雅圖)+類別(餐廳),例如。 「西雅圖餐廳」以及城市(西雅圖)+餐廳名稱(餐廳 - 米開朗基羅)等。 「西雅圖餐廳 - 米開朗基羅」。從結構的角度來看,這當然是一團糟,因爲這不是一個層次結構。在理想的世界裏,等級將是城市 - >類別 - >餐廳。但我仍然希望在我的url結構中適應這種搜索行爲。同時我也有一個列出該國所有餐館的網頁。
我想就如何創建正則表達式以及創建它們的最有效方式提供幫助,因爲我猜它們可能會變得相當昂貴。
感謝
托馬斯
你怎麼一個區分類別和名稱?所有的名字都有破折號或者什麼? – user1096188 2012-02-03 17:40:12