以下是這個場景,我有一個網站,它曾經是一個靜態HTML網站,並且使用子域名(http://blog.domain.com)作爲WordPress博客。.htaccess基於URL中路徑的存在進行重寫
我最近將所有內容組合成一個WordPress安裝。爲了維護舊鏈接,我必須將「http://blog.domain.com/index.php/2010/10/16/post-name」之類的請求重寫爲「http://domain.com/index.php/2010/10/16 /後名稱」。我的問題是,當試圖訪問「http://blog.domain.com」時,當我想要轉到「http://domain.com/」時,我被重定向到「http://domain.com」。的index.php /博客」。
因此,如果用戶請求「http://blog.domain.com」(本身有或沒有斜槓),我希望它轉到「http://domain.com/index.php/」博客」。如果他們請求「http://blog.domain.com/some-link-to-a-post」的舊網址,我希望它重定向到「http://domain.com/some-link-to-一個帖子」。換句話說,如果它是一個實際文章的URL,我只想剝離「博客」子域名。如果是舊的鏈接到主博客頁面,我想刪除「博客」子域並追加「/index.php/blog」
http://blog.domain.com/ - >HTTP ://domain.com/index.php/blog
http://blog.domain.com/index.php/2010/10/16/post-title - >HTTP://域.com/index.php/2010/10/16/post-title
希望這是明確的。我不是一個htaccess專家,所以希望有人能幫助我。提前致謝!