﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-重装上阵-随笔分类-环境配置</title><link>http://www.blogjava.net/cctvx1/category/17760.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 08:51:28 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 08:51:28 GMT</pubDate><ttl>60</ttl><item><title>Apache mod_rewrite</title><link>http://www.blogjava.net/cctvx1/archive/2007/01/30/96805.html</link><dc:creator>Dr.Water</dc:creator><author>Dr.Water</author><pubDate>Tue, 30 Jan 2007 15:06:00 GMT</pubDate><guid>http://www.blogjava.net/cctvx1/archive/2007/01/30/96805.html</guid><wfw:comment>http://www.blogjava.net/cctvx1/comments/96805.html</wfw:comment><comments>http://www.blogjava.net/cctvx1/archive/2007/01/30/96805.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cctvx1/comments/commentRss/96805.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cctvx1/services/trackbacks/96805.html</trackback:ping><description><![CDATA[
		<p>主要就是正则表达式的运用,除了mod_rewrite之外还有一个urlrewritefilter<br />下面是一个测试二级域名映射规则<br /><br />RewriteEngine On<br />RewriteCond %{HTTP_HOST} ^[^www.]+.test.ecom$<br />Rewriterule ^(.+) %{HTTP_HOST}$1 [C]  <br />Rewriterule ^([^www.]+)\.test\.ecom(.*) /shop_$1$2<br />Rewriterule ^www.test.ecom(.*) /$1 [nc,PT]<br />RewriteRule /shop_(.+)/pic/(.*)$ /pic/$2 [nc,PT]<br />RewriteRule /shop_(.+)/js/(.*)$ /js/$2 [nc,PT]<br />RewriteRule /shop_(.+)/css/(.*)$ /css/$2 [nc,PT]<br />RewriteRule /shop_(.+)/(.+).do?(\.*)$  /$2.do?domainName=$1&amp;%{QUERY_STRING} [L,nc]</p>
		<p>
				<br />RewriteLog "logs/rewrite.log"<br />RewriteLogLevel 3<br /><br /><br />关键字段:<br />                RewriteCond 表示如果条件满足则使用下面的Rewriterule<br />                Rewriterule 就是采用具体的正则表达式来匹配 <br />                                    Rewriterule 后面还可以带有参数<br /><br />             见apache参考<br />           <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html</a><br />          </p>
		<ul>
				<li>'<strong><code>chain|C</code></strong>' (<strong>c</strong>hained with next rule)<br />This flag chains the current rule with the next rule (which itself can be chained with the following rule, and so on). This has the following effect: if a rule matches, then processing continues as usual - the flag has no effect. If the rule does <strong>not</strong> match, then all following chained rules are skipped. For instance, it can be used to remove the ``<code>.www</code>'' part, inside a per-directory rule set, when you let an external redirect happen (where the ``<code>.www</code>'' part should not occur!). 
</li>
				<li>'<strong><code>cookie|CO=</code></strong><em>NAME</em>:<em>VAL</em>:<em>domain</em>[:<em>lifetime</em>[:<em>path</em>]]' (set <strong>co</strong>okie)<br />This sets a cookie in the client's browser. The cookie's name is specified by <em>NAME</em> and the value is <em>VAL</em>. The <em>domain</em> field is the domain of the cookie, such as '.apache.org', the optional <em>lifetime</em> is the lifetime of the cookie in minutes, and the optional <em>path</em> is the path of the cookie 
</li>
				<li>'<strong><code>env|E=</code></strong><em>VAR</em>:<em>VAL</em>' (set <strong>e</strong>nvironment variable)<br />This forces an environment variable named <em>VAR</em> to be set to the value <em>VAL</em>, where <em>VAL</em> can contain regexp backreferences (<code>$N</code> and <code>%N</code>) which will be expanded. You can use this flag more than once, to set more than one variable. The variables can later be dereferenced in many situations, most commonly from within XSSI (via <code>&lt;!--#echo var="VAR"--&gt;</code>) or CGI (<code>$ENV{'VAR'}</code>). You can also dereference the variable in a later RewriteCond pattern, using <code>%{ENV:VAR}</code>. Use this to strip information from URLs, while maintaining a record of that information. 
</li>
				<li>'<strong><code>forbidden|F</code></strong>' (force URL to be <strong>f</strong>orbidden)<br />This forces the current URL to be forbidden - it immediately sends back a HTTP response of 403 (FORBIDDEN). Use this flag in conjunction with appropriate RewriteConds to conditionally block some URLs. 
</li>
				<li>'<strong><code>gone|G</code></strong>' (force URL to be <strong>g</strong>one)<br />This forces the current URL to be gone - it immediately sends back a HTTP response of 410 (GONE). Use this flag to mark pages which no longer exist as gone. 
</li>
				<li>'<strong><code>handler|H</code></strong>=<em>Content-handler</em>' (force Content <strong>h</strong>andler)<br />Force the Content-handler of the target file to be <em>Content-handler</em>. For instance, this can be used to simulate the <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html">mod_alias</a></code> directive <code class="directive"><a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#scriptalias">ScriptAlias</a></code>, which internally forces all files inside the mapped directory to have a handler of ``<code>cgi-script</code>''. 
</li>
				<li>'<strong><code>last|L</code></strong>' (<strong>l</strong>ast rule)<br />Stop the rewriting process here and don't apply any more rewrite rules. This corresponds to the Perl <code>last</code> command or the <code>break</code> command in C. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('<code>/</code>') to a real one, <em>e.g.</em>, '<code>/e/www/</code>'. 
</li>
				<li>'<strong><code>next|N</code></strong>' (<strong>n</strong>ext round)<br />Re-run the rewriting process (starting again with the first rewriting rule). This time, the URL to match is no longer the original URL, but rather the URL returned by the last rewriting rule. This corresponds to the Perl <code>next</code> command or the <code>continue</code> command in C. Use this flag to restart the rewriting process - to immediately go to the top of the loop.<br /><strong>Be careful not to create an infinite loop!</strong></li>
				<li>'<strong><code>nocase|NC</code></strong>' (<strong>n</strong>o <strong>c</strong>ase)<br />This makes the <em>Pattern</em> case-insensitive, ignoring difference between 'A-Z' and 'a-z' when <em>Pattern</em> is matched against the current URL. 
</li>
				<li>'<strong><code>noescape|NE</code></strong>' (<strong>n</strong>o URI <strong>e</strong>scaping of output)<br />This flag prevents mod_rewrite from applying the usual URI escaping rules to the result of a rewrite. Ordinarily, special characters (such as '%', '$', ';', and so on) will be escaped into their hexcode equivalents ('%25', '%24', and '%3B', respectively); this flag prevents this from happening. This allows percent symbols to appear in the output, as in 
<div class="example"><p><code>RewriteRule /foo/(.*) /bar?arg=P1\%3d$1 [R,NE] </code></p></div>which would turn '<code>/foo/zed</code>' into a safe request for '<code>/bar?arg=P1=zed</code>'. 
</li>
				<li>'<strong><code>nosubreq|NS</code></strong>' (<strong>n</strong>ot for internal <strong>s</strong>ub-requests)<br />This flag forces the rewriting engine to skip a rewriting rule if the current request is an internal sub-request. For instance, sub-requests occur internally in Apache when <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_include.html">mod_include</a></code> tries to find out information about possible directory default files (<code>index.xxx</code> files). On sub-requests it is not always useful, and can even cause errors, if the complete set of rules are applied. Use this flag to exclude some rules.<br />To decide whether or not to use this rule: if you prefix URLs with CGI-scripts, to force them to be processed by the CGI-script, it's likely that you will run into problems (or significant overhead) on sub-requests. In these cases, use this flag. 
</li>
				<li>'<strong><code>proxy|P</code></strong>' (force <strong>p</strong>roxy)<br />This flag forces the substitution part to be internally sent as a proxy request and immediately (rewrite processing stops here) put through the <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">proxy module</a>. You must make sure that the substitution string is a valid URI (typically starting with <code>http://</code><em>hostname</em>) which can be handled by the Apache proxy module. If not, you will get an error from the proxy module. Use this flag to achieve a more powerful implementation of the <a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass">ProxyPass</a> directive, to map remote content into the namespace of the local server. 
<p>Note: <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">mod_proxy</a></code> must be enabled in order to use this flag.</p></li>
				<li>'<strong><code>passthrough|PT</code></strong>' (<strong>p</strong>ass <strong>t</strong>hrough to next handler)<br />This flag forces the rewrite engine to set the <code>uri</code> field of the internal <code>request_rec</code> structure to the value of the <code>filename</code> field. This flag is just a hack to enable post-processing of the output of <code>RewriteRule</code> directives, using <code>Alias</code>, <code>ScriptAlias</code>, <code>Redirect</code>, and other directives from various URI-to-filename translators. For example, to rewrite <code>/abc</code> to <code>/def</code> using <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a></code>, and then <code>/def</code> to <code>/ghi</code> using <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html">mod_alias</a></code>: 
<div class="example"><p><code>RewriteRule ^/abc(.*) /def$1 [PT]<br />Alias /def /ghi </code></p></div>If you omit the <code>PT</code> flag, <code>mod_rewrite</code> will rewrite <code>uri=/abc/...</code> to <code>filename=/def/...</code> as a full API-compliant URI-to-filename translator should do. Then <code>mod_alias</code> will try to do a URI-to-filename transition, which will fail. 
<p>Note: <strong>You must use this flag if you want to mix directives from different modules which allow URL-to-filename translators</strong>. The typical example is the use of <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html">mod_alias</a></code> and <code class="module"><a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">mod_rewrite</a></code>.</p></li>
				<li>'<strong><code>qsappend|QSA</code></strong>' (<strong>q</strong>uery <strong>s</strong>tring <strong>a</strong>ppend)<br />This flag forces the rewrite engine to append a query string part of the substitution string to the existing string, instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule. 
</li>
				<li>'<strong><code>redirect|R</code> [=<em>code</em>]</strong>' (force <a id="redirect" name="redirect"><strong>r</strong>edirect</a>)<br />Prefix <em>Substitution</em> with <code>http://thishost[:thisport]/</code> (which makes the new URL a URI) to force a external redirection. If no <em>code</em> is given, a HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want to use other response codes in the range 300-400, simply specify the appropriate number or use one of the following symbolic names: <code>temp</code> (default), <code>permanent</code>, <code>seeother</code>. Use this for rules to canonicalize the URL and return it to the client - to translate ``<code>/~</code>'' into ``<code>/u/</code>'', or to always append a slash to <code>/u/</code><em>user</em>, etc.<br /><strong>Note:</strong> When you use this flag, make sure that the substitution field is a valid URL! Otherwise, you will be redirecting to an invalid location. Remember that this flag on its own will only prepend <code>http://thishost[:thisport]/</code> to the URL, and rewriting will continue. Usually, you will want to stop rewriting at this point, and redirect immediately. To stop rewriting, you should add the 'L' flag. 
</li>
				<li>'<strong><code>skip|S</code></strong>=<em>num</em>' (<strong>s</strong>kip next rule(s))<br />This flag forces the rewriting engine to skip the next <em>num</em> rules in sequence, if the current rule matches. Use this to make pseudo if-then-else constructs: The last rule of the then-clause becomes <code>skip=N</code>, where N is the number of rules in the else-clause. (This is <strong>not</strong> the same as the 'chain|C' flag!) 
</li>
				<li>'<strong><code>type|T</code></strong>=<em>MIME-type</em>' (force MIME <strong>t</strong>ype)<br />Force the <a class="glossarylink" title="see glossary" href="http://httpd.apache.org/docs/2.2/glossary.html#mime-type">MIME-type</a> of the target file to be <em>MIME-type</em>. This can be used to set up the content-type based on some conditions. For example, the following snippet allows <code>.php</code> files to be <em>displayed</em> by <code>mod_php</code> if they are called with the <code>.phps</code> extension: 
<div class="example"><p><code>RewriteRule ^(.+\.php)s$ $1 [T=application/x-httpd-php-source] </code></p></div></li>
		</ul>
		<p>
				<br />                 </p>
<img src ="http://www.blogjava.net/cctvx1/aggbug/96805.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cctvx1/" target="_blank">Dr.Water</a> 2007-01-30 23:06 <a href="http://www.blogjava.net/cctvx1/archive/2007/01/30/96805.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache 2.2 和 Subversion整合</title><link>http://www.blogjava.net/cctvx1/archive/2006/11/27/83682.html</link><dc:creator>Dr.Water</dc:creator><author>Dr.Water</author><pubDate>Sun, 26 Nov 2006 16:14:00 GMT</pubDate><guid>http://www.blogjava.net/cctvx1/archive/2006/11/27/83682.html</guid><wfw:comment>http://www.blogjava.net/cctvx1/comments/83682.html</wfw:comment><comments>http://www.blogjava.net/cctvx1/archive/2006/11/27/83682.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cctvx1/comments/commentRss/83682.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cctvx1/services/trackbacks/83682.html</trackback:ping><description><![CDATA[
		<p>
				<font face="Courier New" size="2">Apache 2.2.3 Subversion 1.4.0(r21228) integrate <br />reference :<br />          </font>
				<a href="http://xrinehart.cnblogs.com/archive/2005/10/27/262759.html">
						<font face="Courier New" size="2">http://xrinehart.cnblogs.com/archive/2005/10/27/262759.html</font>
				</a>
				<br />
				<font face="Courier New" size="2">          </font>
				<a href="http://xrinehart.cnblogs.com/archive/2005/10/29/264659.html">
						<font face="Courier New" size="2">http://xrinehart.cnblogs.com/archive/2005/10/29/264659.html</font>
				</a>
				<br />
				<font face="Courier New" size="2">          </font>
				<a href="http://www.apachelounge.com/forum/viewtopic.php?t=121">
						<font face="Courier New" size="2">http://www.apachelounge.com/forum/viewtopic.php?t=121</font>
				</a>
				<br />
				<font face="Courier New" size="2">                      (maniac provide svn 1.4.0 module win32  binary for apache 2.2.x)<br />Warning:<br />        subversion.tigris.org<br />        Windows binaries - ATTENTION!: The mod_dav_svn binaries available here are NOT compatible with Apache 2.2</font>
		</p>
		<p>
				<font face="Courier New" size="2">FAQ:<br />     Error:  Expected fromat '3' of repository;found format '5' <br />             use "--pre-1.4-compatible", default format is "5" !!<br />            <br />Integrate Guide:<br />            I  use other complie svn module for apache 2.2.3 ,<br />     Step1: <br />             copy *.dll to  %APACHE_HOME%\bin<br />             copy *.so  to  %APACHE_HOME%\modules<br />     Step2:<br />             edit %APACHE_HOME%\conf\httpd.conf<br />             find:<br />                 #LoadModule dav_module  modules\mod_dav.so<br />                 #LoadModule dav_fs_module modules\mod_dav_fs.so<br />             change: "#" to ""<br />                 LoadModule dav_module  modules\mod_dav.so<br />                 LoadModule dav_fs_module modules\mod_dav_fs.so<br />             and add SVN Module:<br />                 #SVN <br />                 LoadModule dav_svn_module   modules\mod_dav_svn.so<br />                 LoadModule authz_svn_module  modules\mod_authz_svn.so<br />      Step3:  <br />              config  SVN auth,add httpd.conf<br />              use apache basic auth,gen password file <br />                %APACHE_HOME%\bin\htpasswd -cm D:/server/webservice/clear/Apache2.2/svn-auth/svn-auth-file harry</font>
		</p>
		<p>
				<font face="Courier New" size="2">                &lt;IfModule dav_svn_module&gt;<br />                 &lt;Location /svn&gt;<br />                   DAV svn<br />                   SVNParentPath D:/SubversionRoot<br />                   AuthTypeBasic<br />                   AuthName "Subversion Repository"<br />                   AuthUserFile D:/server/webservice/clear/Apache2.2/svn-auth/svn-auth-file<br />       Require valid-user<br />                 &lt;/Location&gt;<br />                &lt;/IfModule&gt;<br />       <br />主要就是svn官方的win binary不支持apache 2.2的新module调用。<br />       </font>
		</p>
		<p>
				<font face="Courier New" size="2">                 </font>
		</p>
		<p>
				<font face="Courier New" size="2">
				</font> </p>
<img src ="http://www.blogjava.net/cctvx1/aggbug/83682.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cctvx1/" target="_blank">Dr.Water</a> 2006-11-27 00:14 <a href="http://www.blogjava.net/cctvx1/archive/2006/11/27/83682.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>