求教,關於Rewrite中的路徑問題。

來源:互聯網
上載者:User
原本似乎是應該在Apache版塊求教的。不過,剛剛問了一次,那裡似乎太冷清了。到時先前在這裡的請教有比較好的回覆。所以重新發帖求教了。

環境描述:
/target.html
/images/image1.png

target.html中引用image1.png:src="images/image1.png"

做URL重寫
RewriteRule /paht/source.html target.html

出現的情況是:
呈現的頁面中,對於images/image1.png的引用,變成了引用path/images/image1.png。
So, 頁面片沒了。

請問,該如何解決呢?


回複討論(解決方案)

你的重寫規則時這樣寫的:RewriteRule /paht/source.html target.html
如果不是請貼出詳細,方便我們分析。

你的重寫規則時這樣寫的:RewriteRule /paht/source.html target.html
如果不是請貼出詳細,方便我們分析。

首先,感謝賜教。

您寫的這個重寫規則,跟我原本寫的似乎區別不大,或者我沒看出來。
頁面的重新是實現了,但是,出現了資源引用問題。
原本那個target.html裡面,有個
target.html、images目錄、path目錄,這三個項目在目錄結構中是同級的。
那麼,上述標籤在/path/source.html中呈現之後,就變成了請求/path/images/image1.png。
這樣……,圖片呈現不出來了。

引用 1 樓 nowphp 的回複:你的重寫規則時這樣寫的:RewriteRule /paht/source.html target.html
如果不是請貼出詳細,方便我們分析。

首先,感謝賜教。

您寫的這個重寫規則,跟我原本寫的似乎區別不大,或者我沒看出來。
頁面的重新是實現了,但是,出現了資源引用問題。
原本那個target.html裡面,有個

target.html中引用image1.png:src="images/image1.png"

修改為

target.html中引用image1.png:src="/images/image1.png"

target.html中引用image1.png:src="images/image1.png"

修改為

target.html中引用image1.png:src="/images/image1.png"

這種做法,需要修改大量的頁面上的資源引用,工作量太大了。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.