1
0
mirror of https://github.com/apache/httpd.git synced 2026-01-06 09:01:14 +03:00

Replaces the two-step process with a single rule using the RewriteCond

backreference. This technique is far simpler, and far easier to explain
to beginners than the unnecessarily complicated technique used.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@884943 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rich Bowen
2009-11-27 18:27:26 +00:00
parent c195b5231b
commit 3d05ffe29e
4 changed files with 18 additions and 22 deletions

View File

@@ -356,8 +356,10 @@ RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-
<h2><a name="homepages.rewrite" id="homepages.rewrite">A
Homepages System Using <code>mod_rewrite</code></a></h2>
<p>This does the same thing as <a href="#homepages">the second
example</a>.</p>
<p>This is similar to <a href="#homepages">the one above</a>,
but also verifies that the hostname falls into a specific subset of
hostnames - in this case, that it looks like
<code>www.<strong>SITE</strong>.example.com</code>.</p>
<div class="example"><p><code>
RewriteEngine on<br />
@@ -367,15 +369,11 @@ RewriteMap lowercase int:tolower<br />
# allow CGIs to work<br />
RewriteCond %{REQUEST_URI} !^/cgi-bin/<br />
<br />
# check the hostname is right so that the RewriteRule works<br />
RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.[a-z-]+\.isp\.com$<br />
# Capture the site name in the backreference variable %1<br />
RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.([a-z-]+)\.example\.com$<br />
<br />
# concatenate the virtual host name onto the start of the URI<br />
# the [C] means do the next rewrite on the result of this one<br />
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]<br />
<br />
# now create the real file name<br />
RewriteRule ^www\.([a-z-]+)\.isp\.com/(.*) /home/$1/$2<br />
# Map the request to the site's document directory<br />
RewriteRule ^(.*) /home/%1/$1<br />
<br />
# define the global CGI directory<br />
ScriptAlias /cgi-bin/ /www/std-cgi/

View File

@@ -349,8 +349,10 @@ RewriteRule ^/(.*)$ /www/hosts/${lowercase:%{SERVER_NAME}}/cgi-bin/$1 [H=cgi-
<section id="homepages.rewrite"><title>A
Homepages System Using <code>mod_rewrite</code></title>
<p>This does the same thing as <a href="#homepages">the second
example</a>.</p>
<p>This is similar to <a href="#homepages">the one above</a>,
but also verifies that the hostname falls into a specific subset of
hostnames - in this case, that it looks like
<code>www.<strong>SITE</strong>.example.com</code>.</p>
<example>
RewriteEngine on<br />
@@ -360,15 +362,11 @@ RewriteMap lowercase int:tolower<br />
# allow CGIs to work<br />
RewriteCond %{REQUEST_URI} !^/cgi-bin/<br />
<br />
# check the hostname is right so that the RewriteRule works<br />
RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.[a-z-]+\.isp\.com$<br />
# Capture the site name in the backreference variable %1<br />
RewriteCond ${lowercase:%{SERVER_NAME}} ^www\.([a-z-]+)\.example\.com$<br />
<br />
# concatenate the virtual host name onto the start of the URI<br />
# the [C] means do the next rewrite on the result of this one<br />
RewriteRule ^(.+) ${lowercase:%{SERVER_NAME}}$1 [C]<br />
<br />
# now create the real file name<br />
RewriteRule ^www\.([a-z-]+)\.isp\.com/(.*) /home/$1/$2<br />
# Map the request to the site's document directory<br />
RewriteRule ^(.*) /home/%1/$1<br />
<br />
# define the global CGI directory<br />
ScriptAlias /cgi-bin/ /www/std-cgi/

View File

@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='EUC-KR' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.ko.xsl"?>
<!-- English Revision: 151408:884925 (outdated) -->
<!-- English Revision: 151408:884934 (outdated) -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more

View File

@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.tr.xsl"?>
<!-- English Revision: 659902:884925 (outdated) -->
<!-- English Revision: 659902:884934 (outdated) -->
<!-- =====================================================
Translated by: Nilgün Belma Bugüner <nilgun belgeler.org>
Reviewed by: Orhan Berent <berent belgeler.org>