![從 DotClear 遷移:重寫 feed 的 url](https://rvso.com/image/593947/%E5%BE%9E%20DotClear%20%E9%81%B7%E7%A7%BB%EF%BC%9A%E9%87%8D%E5%AF%AB%20feed%20%E7%9A%84%20url.png)
我已將我的部落格從 DotClear2 遷移到 WP3。
我想在我的 NGinx 設定檔中添加一些 URL 重寫,以便使用 RSS 關注我的部落格的人仍然可以執行相同的操作,而無需更改聚合器中的地址。
之前的網址是:http://www.emidee.net/blog/index.php/feed/atom而新的是:http://www.emidee.net/index.php/feed/atom
我如何在 NGINX 中編寫重寫規則,以便它可以自動傳輸到新的 URL?
簡而言之,我想去掉 URL 中的 /blog/ 一詞。
謝謝!
答案1
這應該夠了:
server {
# more code ...
location / {
# more code ...
location ~* ^/blog/([a-z0-9\.]+)$ {
return 301 $scheme://$server_name$1;
}
# more code ...
}
}
答案2
經過一些不成功的嘗試後,這個似乎運作得很好
server {
listen 80;
server_name www.emidee.net emidee.net;
root /var/www/http/emidee;
include global.conf.d/restrictions.conf;
include global.conf.d/wordpress.conf;
rewrite ^/blog(.*)$ $scheme://$server_name$1 last;
}