我想隱藏我的網頁的擴展,使:簡單的mod_rewrite隱藏擴展名
/page
/page/
/page.html
所有重定向到page.html
。
這個討論有幾乎工作的解決方案:How to hide the .html extension with Apache mod_rewrite
但使用/page/
時,需要考慮到尾隨斜線作爲文件夾指示,因此在這個HTML文件的所有鏈接和相對路徑去,說/page/style.css
,而不是/style.css
。
這是我目前的.htaccess
:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
如何解決呢?
如果您因重複而投票結束,請將我轉發給副本。或者顯而易見的谷歌結果。我還沒有找到。 – Lazlo 2012-01-12 01:44:16