apache mod_rewrite: 把首页URL重写为另一个URL

试了半天,发现要这样写才行

引用

        RewriteEngine on

        RewriteRule ^/$ /homepage/index.htm  [PT]

1. 首页"/"前后要用^和$包裹起来,表示只重写首页

2. 如果不写[PT],apache就会去linux根目录(而不是应用根目录)查找 /homepage/index.htm这个文件

3. 如果把[PT]改成[R],则会发现302跳转,用户的浏览器里会出现http://…/homepage/index.htm

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.