關於nginx rewrite問題
在論壇伺服器上想做一個跳轉
比如訪問http://bbs.111.cn/45678 就直接跳轉到論壇裡面的某個板塊http://bbs.111.cn/forum-22-1.html
其中45678在伺服器上沒有這個目錄
location /45678 {
rewrite ^(.*)$ http://bbs.111.cn/forum-22-1.html last;
break;
}
現在訪問http://bbs.111.cn/45678 總是提示錯誤
而在這URL後面加斜杠訪問http://bbs.111.cn/45678/ 就沒有問題
《解決方案》
if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}:wink:
目錄自動加「/」 嘻嘻:)
《解決方案》
我加過這句話了,不起作用阿
location /45678 {
if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
rewrite ^(.*)$ http://bbs.111.cn/forum-22-1.html last;
break;
}
《解決方案》
rewrite ^/45678.*$ /forum-22-1.html last;
《解決方案》
try location /45678*
《解決方案》
server {
server_name bbs.111.cn;
location ^~ /45678/ {
rewrite ^/sh/(.*) http://bbs.111.cn/forum-22-1.html permanent;
}
《解決方案》
重寫規則,好難啊