nginx的一些規則案例備忘
xxx:
http://home.hao123.com/wiki/wiki.asp?/=xxx 301到 http://home.hao123.com/wiki/index/c/xxx
location ~ wiki.asp {
if ( $query_string ~* “=(d+)$” ) {
set $cc $1;
set $args “;
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/wiki/index/c/$cc permanent;
}
}
http://home.hao123.com/wiki/wikiview.asp?/=xxx 301到 http://home.hao123.com/wiki/view/id/xxx
location ~ wikiview.asp {
if ($query_string ~* “=(d+)$” ) {
set $cc $1;
set $args “;
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/wiki/view/id/$cc permanent;
}
}
1列表頁:http://home.hao123.com/zhuangshi/list.asp 301到 http://jmall.sina.com/Company/cList/
rewrite ^/zhuangshi/list.asp http://jmall.sina.com/Company/cList/ permanent;
2列表頁:http://home.hao123.com/design/ 301到 http://jmall.sina.com/Company/styleList
rewrite ^/design http://jmall.sina.com/Company/styleList permanent;
相簿首頁
http://home.hao123.com/photo/zhuangxiu.asp 301到 http://home.hao123.com/photo/
rewrite ^/photo/zhuangxiu.asp http://home.hao123.com/photo/ permanent;
相簿分類頁
http://home.hao123.com/photo/jiaju.asp 301到 http://home.hao123.com/photo/showlist/pid/6
rewrite ^/photo/jiaju.asp http://home.hao123.com/photo/showlist/pid/6 permanent;
相簿內頁
http://home.hao123.com/photo/phoList.asp?/=xxx 301到 http://home.hao123.com/photo/show/id/xxx#p=1
location ~ /photo/phoList.asp {
if ( $query_string ~* “=(d+)$” ) {
set $cc $1;
set $args “;
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/photo/show/id/$cc#p=1 permanent;
}
}
http://home.hao123.com/photo/list.asp?classId=xxx 301到 http://home1.hao123.com/photo/showlist/cid/xxx
location ~ /photo/list.asp {
if ( $query_string ~* “=(d+)$” ) {
set $cc $1;
set $args “;
# rewrite ^ $scheme://$host/test/$cc.mp3 permanent;
rewrite ^ http://home1.hao123.com/photo/showlist/cid/$cc permanent;
}
}
http://home.hao123.com/*** 以上未定義的 直接跳轉到 http://home.hao123.com/
if (!-e $request_filename) {
rewrite ^(.*)$ http://home1.hao123.com last;
}
ps:xxx 代表數字ID
http://ng1.qq.com/tv/list.asp?areaid=33 301 到 http://ng1.qq.com/tv/lists/areaid/33
if ($request_uri ~ “^/tv/list.asp?areaid=([d]+)$”)
{
set $q $1;
rewrite .* /tv/lists/areaid/$q? permanent;
}
訪問 http://ng.qq.com/html/2013-07-29/1035590.html 內容顯示 http://ng.qq.com/html/2013/07/29/1035590.html
rewrite “^/html/(d+)-(d+)-(d+)/(.*).html$” /html/$1/$2/$3/$4.html last;
http://news.qq.com/index.php?m=html&a=Other&date=130806&par=31MTR1375752599_1 重寫成 http://news.qq.com/html/Other/130806/31MTR1375752599_1.html
rewrite ^(.*)/(w+)/(w+)/(d+)/(w+).html$ $1/index.php?m=$2&a=$3&date=$4&par=$5 last;
訪問 3g.ah.qq.com跳到m.ah.qq.com
if ($host ~* “^3g.(.*).qq.com”) {
set $domain $1;
rewrite ^/(.*) http://m.$domain.qq.com/$1 last;
}
http://www.ah.cn/newsshow.php?siteid=2&cid=4&id=9&page=1偽靜態成
http://www.ah.cn/newsshow-4-9-1.html
rewrite ^/newsshow-([0-9]+)-([0-9]+)-([0-9]+).html$ /newsshow.php?siteid=2&cid=$1&id=$2&page=$3 last;
本文轉自 liang3391 51CTO部落格,原文連結:http://blog.51cto.com/liang3391/1174610
相關文章
- Nginx 配置檔案備忘Nginx
- nginx location匹配規則Nginx
- Nginx 跳轉規則Nginx
- Nginx Rewrite規則初探Nginx
- Nginx的location配置規則梳理Nginx
- Python小白必備:字串基礎,規則與案例Python字串
- ubuntu 16.04一些備忘Ubuntu
- nginx的location 規則匹配練習Nginx
- Nginx的Rewrite規則與例項Nginx
- Nginx匹配規則練習Nginx
- Nginx 重寫規則指南Nginx
- 玩ubuntu6.10的一些備忘Ubuntu
- 備忘錄--最近一些總結
- nginx location匹配及rewrite規則Nginx
- sql語句的一些規則SQL
- 【記錄】那些很實用的Nginx規則Nginx
- Nginx常用Rewrite偽靜態規則Nginx
- Go程式設計的一些規則Go程式設計
- JS常用正規表示式備忘錄JS
- 重建物理備庫案例兩則
- python + selenium + chrome headless 的一些備忘PythonChrome
- 第七章:nginx的rewrite規則詳解Nginx
- Nginx URL重寫規則配置詳解Nginx
- PbootCMS網站nginx偽靜態規則boot網站Nginx
- 規則引擎模式的.NET開源專案案例模式
- 【譯】JS常用正規表示式備忘錄JS
- Nginx伺服器常見配置清單備忘錄Nginx伺服器
- 理解 Nginx 在處理請求時的匹配規則Nginx
- Nginx接收的host值會影響alias的規則匹配Nginx
- nginx location規則優先順序比較Nginx
- Nginx rewrite 規則 與 proxy_pass 實現Nginx
- MySQL鎖(四)行鎖的加鎖規則和案例MySql
- JavaScript正規表示式備忘單附例項JavaScript
- 【備忘】《圖解Spark 核心技術與案例實戰》PDF圖解Spark
- nginx配置location總結及rewrite規則寫法Nginx
- RunLoop備忘OOP
- Vuepress 備忘Vue
- MySQL備忘MySql