⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1252.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 3 页
字号:
---- allowoverride all<br>
---- &lt; /Directory &gt;<br>
<br>
六、应用举例<br>
<br>
---- 假定Apache被编译安装在主机192.168.1.56的/usr/local/apache目录下面,同时编译了重写和代理模块。<br>
<br>
---- 1.隐藏Apache下的某个目录,使得对该目录的任何请求都重定向到另一个文件<br>
---- (1)httpd.conf的实现方法<br>
---- 我们将下面的部分放到/usr/local/apache/conf/httpd.conf中。<br>
<br>
---- &lt; Directory "/usr/local/apache/htdocs/manual/"&gt; options Indexes followsymlinks<br>
---- allowoverride all<br>
---- rewriteengine on<br>
---- rewritebase /<br>
---- rewriterule ^(.*)$ index.html.en [R=301]<br>
---- &lt; /Directory &gt;<br>
<br>
---- 注: “rewriteengine on”为重写引擎开关,如果设为“off”,则任何重写规则定义将不被应用,该开关的另一用处就是如果为了临时去掉重写规则,可以将引擎开关设为“off”再重新启动Apache即可,不必将其中的各条重写规则注释掉。<br>
<br>
---- “rewritebase /”的作用是如果在下面的rewriterule定义中被重写后的部分(此处为文件名index.html.en)前面没有“/”,则表明是相对目录,相对于这个rewritebase后面的定义也就是/usr/local/apache/htdocs/index.html.en,否则,如果此处没有“rewritebase /”这一项,则被重写成http://192.168.1.56/usr/local/apache/htdocs/manual/index.html.en,显然是不正确的。<br>
<br>
---- 我们也可以不用“rewritebase /”,而是将其改为如下部分。<br>
---- rewriteengine on<br>
---- rewriterule ^(.*)$ /index.html.en [R=301]<br>
---- 或者更改为:<br>
---- rewriteengine on<br>
---- rewriterule ^(.*)$ http://192.168.1.56/index.html.en [R=301]<br>
<br>
---- (2).htaccess的实现方法<br>
---- 我们将下面的部分放到httpd.conf中。<br>
<br>
---- &lt; Directory "/usr/local/apache/htdocs/manual/"&gt; options Indexes followsymlinks<br>
---- allowoverride all<br>
---- &lt; /Directory &gt;<br>
<br>
---- 然后将下面的部分放到/usr/local/apache/htdocs/manual/.htaccess中。<br>
---- rewriteengine on<br>
---- rewritebase /<br>
---- rewriterule ^(.*)$ index.html.en [R=301]<br>
<br>
---- 注: 对文件.htaccess所做的任何改动不需要重启动Apache。<br>
<br>
---- 您还可以利用.htaccess方案将这个manual目录重定向到用户jephe自己的主目录。<br>
---- rewriteengine on<br>
---- rewritebase /~jephe/<br>
---- rewriterule ^(.*)$ $1 [R=301]<br>
<br>
---- 这样,对manual目录下任何文件的请求被重定向到~jephe目录下相同文件的请求。<br>
<br>
---- 2.将http://www.username.domain.com对于username的主页请求转换为对http://www.domain.com/username的请求<br>
---- 对于HTTP/1.1的请求包括一个Host: HTTP头,我们能用下面的规则集重写http://www.username.domain .com/anypath到/home/username/anypath。<br>
---- rewriteengine on<br>
---- rewritecond %{HTTP_HOST} ^www.[^.]+.host.com$<br>
---- rewriterule ^(.+) %{HTTP_HOST}$1 [C]<br>
---- rewriterule ^www.([^.]+).host.com(.*) /home/$1$2<br>
<br>
---- 注: “rewritecond”表明是条件重写规则,当满足后面定义的条件后才会应用下面的重写规则,“rewritecond”有各种变量,请查阅相关文档。<br>
<br>
---- 3.防火墙上的重写规则代理内部网段上服务器的请求<br>
---- NameVirtualhost 1.2.3.4<br>
---- &lt; Virtualhost 1.2.3.4:80 &gt; servername www.domain.com<br>
---- rewriteengine on<br>
---- proxyrequest on<br>
---- rewriterule ^/(.*)$ http://192.168.1.3/$1 [P,L]<br>
---- &lt; /Virtualhost &gt;<br>
<br>
---- 注: 当外部浏览器请求http://www.domain.com时,将被解析到IP地址1.2.3.4,Apache交由mod_rewrite处理,转换成http://192.168.1.3/$1后再交由代理模块mod_proxy,得到内容后传送回用户的浏览器。<br>
<br>
---- 4.基本预先设定的转换Map表进行重写rewritemap<br>
---- 转换http://www.domain.com/{countrycode}/anypath到Map表中规定的URL,前面是虚拟主机中的定义。<br>
---- rewritelog /usr/local/apache/logs/rewrite.log<br>
---- rewriteloglevel 9<br>
---- rewriteengine on<br>
---- proxyrequest on<br>
---- rewritemap sitemap txt:/usr/local/apache/conf/rewrite.map<br>
---- rewriterule ^/([^/]+)+/(.*)$ http://%{REMOTE_HOST}::$1 [C]<br>
---- rewriterule (.*):[a-z]+)$ ${sitemap:$2|http://h.i.j.k/} [R=301,L]<br>
---- 文件/usr/local/apache/conf/rewrite.map的内容如下:<br>
---- sg http://a.b.c.d/<br>
---- sh http://e.f.g.h/<br>
<br>
---- 注: 当用户请求http://www.domain.com/sg/anypath时被重写为http://a.b.c.d/anypath。当需要调试时请用rewritelog和 rewriteloglevel 9联合,9为最大,即得到最多的调试信息;最小为1,表示得到最少的调试信息;默认为0,表示没有调试信息。<br>
<br>
---- sitemap的语法是${sitemap: LookupKey | Defaultvalue},有些书上把$写成了%是错误的。
</FONT><br>
                                      </TD>
                                    </TR>
                                <TR>
                                <TD colSpan=2><FONT 
                                class=middlefont></FONT><BR>
                                        <FONT 
                                class=normalfont>全文结束</FONT> </TD>
                                    </TR>
                                <TR>
                                <TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2 
                                height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
                        <TD vAlign=top width="20%" 
                      background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2> 
                          <DIV align=center> 
                            <table class=tableoutline cellspacing=1 cellpadding=4 
                        width="100%" align=center border=0>
                              <tr class=firstalt> 
                                <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
                                <font class=normalfont><b>所有分类</b></font></td>
                              </tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td>    </tr>  </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td>    </tr>  </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%>   <table width=100% border=0>    <tr>       <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td>    </tr>  </table></td></tr>                            </table>
                          </DIV></TD></TR>
                    <TR vAlign=top>
                        <TD width="80%"> 
                          <DIV align=center><BR>
                          </DIV>
                        </TD></TR></TBODY></TABLE></TD></TR>
                </TABLE></TD></TR>
          </TABLE>
      <TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee 
        border=0><TBODY>
        <TR>
          <TD width="50%">
              <P><FONT class=middlefont>版权所有 &copy; 2004 <A 
            href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
                违者必究. </FONT></P>
            </TD>
          <TD width="50%">
              <DIV align=right><FONT class=middlefont>Powered by: <A 
            href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
            </TD></TR></TBODY></TABLE>
      <CENTER></CENTER></TD></TR>
    </TABLE></CENTER></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -