
我想根據使用者來自哪裡提供不同語言的網頁。例如。www.mysite.com/fr
如果使用者來自法國,則 www.mysite/es 如果使用者來自西班牙。它也會被接受www.fr.mysite.com
並且www.es.mysite.com
。
我指的不是這個:內容協商 - Apache HTTP 伺服器。我不希望它像這樣顯示:www.mysite.com/home.es.html
。
答案1
使用 mod_rewrite 將 URL 重寫為您想要的任何內容:
像是使用者請求之類的東西www.mysite/es
和 Apache 會在內部重定向到www.mysite.com/home.es.html
,使用者永遠不必看到www.mysite.com/home.es.html
,它看起來像 URL,www.mysite/es
但實際上它位於www.mysite.com/home.es.html
。