我想隐藏我的网页的扩展,使:简单的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