11
我使用nginx的1.0.8,我想所有的訪客不www.mysite.com/dir到谷歌搜索頁面http://www.google.com/search?q=dir其中dir是一個可變的重定向,但是如果DIR == 「博客」(www.mysite.com/blog)我只是想加載博客內容(WordPress的)。nginx的重定向所有的目錄,除了一個
這裏是我的配置:
location/{
root html;
index index.html index.htm index.php;
}
location /blog {
root html;
index index.php;
try_files $uri $uri/ /blog/index.php;
}
location ~ ^/(.*)$ {
root html;
rewrite ^/(.*) http://www.google.com/search?q=$1 permanent;
}
如果我這樣做,甚至www.mysite.com/blog將被重定向到谷歌搜索頁面。如果我刪除了最後一個位置www.mysite.com/blog很棒。
從我在這裏讀到的:http://wiki.nginx.org/HttpCoreModule#location看來,優先級將首先在正則表達式上,並且匹配查詢的第一個正則表達式將停止搜索。
感謝