财商书苑
全民财商训练提升,认真负责我们的每句话

利用 apache mod rewrite 重定向首页目录

利用 apache mod rewrite 重定向首页目录

### 后面接其他的规则

R|redirect -> 重定向
L|Last -> 匹配到这一条规则后,不想执行后续的规则了,所以要中断。

注:原文中的根目录是 ^/$ 但是在我这里不行,换成 ^$ 则可正常工作。 !_!

 

下面是摘自 apache 移动根文档原文

Moved DocumentRoot

Description:
Usually the DocumentRoot of the webserver directly relates to the URL “/”. But often this data is not really of top-level priority. For example, you may wish for visitors, on first entering a site, to go to a particular subdirectory /about/. This may be accomplished using the following ruleset:

Solution:
We redirect the URL / to /about/:

Note that this can also be handled using the RedirectMatch directive:

Note also that the example rewrites only the root URL. That is, it rewrites a request for http://example.com/, but not a request for http://example.com/page.html. If you have in fact changed your document root – that is, if all of your content is in fact in that subdirectory, it is greatly preferable to simply change your DocumentRoot directive, or move all of the content up one directory, rather than rewriting URLs.

 

 

 

赞(0)
未经允许不得转载:财商书苑-全民财商训练提升 » 利用 apache mod rewrite 重定向首页目录

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址