URL重寫(英語:URL Rewriting)是一種REST的相關技術,它可以在Web Server中,針對使用者所提供的URL進行轉換後,再傳入Web Server中的程式處理器。

範例

最常見的用法,就是將一組URL階層字串,轉換成帶有查詢字符串(query string)的URL,或是反向轉換,例如: http://www.somebloghost.com/Blogs/Posts.php?Year=2006&Month=12&Day=10

經過URL重寫後,可以變成:

http://www.somebloghost.com/Blogs/2006/12/10/

另一個例子,下面的URL:

http://www.somehost.com/Blogs/2006/12/

經過URL重寫後,可轉換成:

http://www.somehost.com/Blogs.aspx?year=2006&month=12

因此,使用者可以使用較直覺的方式來輸入URL(這也是REST的主要目的),是搜尋引擎最佳化(SEO)的作法之一。而應用程式開發者可以利用這個機制來將參數隱藏起來,可避免讓網路上的惡意使用者收集到有利於發動攻擊的資訊。

支援URL Rewriting的處理引擎

Apache HTTP Server

Microsoft Internet Information Server (IIS)

J2EE Servlet

Lighttpd (lighty)

Nginx

參考資料

參見

外部連結

Wikiwand in your browser!

Seamless Wikipedia browsing. On steroids.

Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.

Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.