From: Rich Bowen Date: Wed, 25 Apr 2012 12:50:42 +0000 (+0000) Subject: Update examples to new highlight syntax. X-Git-Tag: 2.5.0-alpha~7039 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87ad54f274db844a3ea3a0e0cd9dc399d881df53;p=apache Update examples to new highlight syntax. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1330252 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/rewrite/intro.html.en b/docs/manual/rewrite/intro.html.en index a2cdf5e5dd..17fff8acad 100644 --- a/docs/manual/rewrite/intro.html.en +++ b/docs/manual/rewrite/intro.html.en @@ -186,18 +186,20 @@ defined.

A full filesystem path to a resource
-

+

 RewriteRule ^/games /usr/local/games/web
-

+ +

This maps a request to an arbitrary location on your filesystem, much like the Alias directive.

A web-path to a resource
-

+

 RewriteRule ^/foo$ /bar
-

+ +

If DocumentRoot is set to /usr/local/apache2/htdocs, then this directive would map requests for http://example.com/foo to the @@ -206,9 +208,10 @@ path /usr/local/apache2/htdocs/bar.

An absolute URL
-

+

 RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]
-

+ +

This tells the client to make a new request for the specified URL.

@@ -216,9 +219,10 @@ RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]

The Substitution can also contain back-references to parts of the incoming URL-path matched by the Pattern. Consider the following:

-

+

 RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1
-

+ +

The variable $1 will be replaced with whatever text was matched by the expression inside the parenthesis in the Pattern. For example, a request @@ -239,9 +243,10 @@ application of one or more flags to the end of the rule. For example, the matching behavior of a rule can be made case-insensitive by the application of the [NC] flag:

-

+

 RewriteRule ^puppy.html smalldog.html [NC]
-

+ +

For more details on the available flags, their meanings, and examples, see the Rewrite Flags document.

@@ -265,10 +270,11 @@ argument is a list of flags that modify how the match is evaluated.

For example, to send all requests from a particular IP range to a different server, you could use:

-

-RewriteCond %{REMOTE_ADDR} ^10\.2\.
+

+RewriteCond %{REMOTE_ADDR} ^10\.2\.
 RewriteRule (.*) http://intranet.example.com$1
-

+ +

When more than one RewriteCond is @@ -277,11 +283,12 @@ the Rewrit applied. For example, to deny requests that contain the word "hack" in their query string, unless they also contain a cookie containing the word "go", you could use:

-

-RewriteCond %{QUERY_STRING} hack
-RewriteCond %{HTTP_COOKIE} !go
+

+RewriteCond %{QUERY_STRING} hack
+RewriteCond %{HTTP_COOKIE} !go
 RewriteRule . - [F]
-

+ +

Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".

Matches in the regular expressions contained in @@ -291,10 +298,11 @@ the Rewrit variables %1, %2, etc. For example, this will direct the request to a different directory depending on the hostname used to access the site:

-

-RewriteCond %{HTTP_HOST} (.*)
+

+RewriteCond %{HTTP_HOST} (.*)
 RewriteRule ^/(.*) /sites/%1/$1
-

+ +

If the request was for http://example.com/foo/bar, then %1 would contain example.com and $1 would contain foo/bar.

diff --git a/docs/manual/rewrite/intro.xml b/docs/manual/rewrite/intro.xml index bc9a335c55..88a64d2e7d 100644 --- a/docs/manual/rewrite/intro.xml +++ b/docs/manual/rewrite/intro.xml @@ -192,18 +192,18 @@ defined.

A full filesystem path to a resource
- + RewriteRule ^/games /usr/local/games/web - +

This maps a request to an arbitrary location on your filesystem, much like the Alias directive.

A web-path to a resource
- + RewriteRule ^/foo$ /bar - +

If DocumentRoot is set to /usr/local/apache2/htdocs, then this directive would map requests for http://example.com/foo to the @@ -212,9 +212,9 @@ path /usr/local/apache2/htdocs/bar.

An absolute URL
- + RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R] - +

This tells the client to make a new request for the specified URL.

@@ -222,9 +222,9 @@ RewriteRule ^/product/view$ http://site2.example.com/seeproduct.html [R]

The Substitution can also contain back-references to parts of the incoming URL-path matched by the Pattern. Consider the following:

- + RewriteRule ^/product/(.*)/view$ /var/web/productdb/$1 - +

The variable $1 will be replaced with whatever text was matched by the expression inside the parenthesis in the Pattern. For example, a request @@ -246,9 +246,9 @@ application of one or more flags to the end of the rule. For example, the matching behavior of a rule can be made case-insensitive by the application of the [NC] flag:

- + RewriteRule ^puppy.html smalldog.html [NC] - +

For more details on the available flags, their meanings, and examples, see the Rewrite Flags document.

@@ -274,10 +274,10 @@ argument is a list of flags that modify how the match is evaluated.

For example, to send all requests from a particular IP range to a different server, you could use:

- -RewriteCond %{REMOTE_ADDR} ^10\.2\.
+ +RewriteCond %{REMOTE_ADDR} ^10\.2\. RewriteRule (.*) http://intranet.example.com$1 -
+

When more than one RewriteCond is @@ -286,11 +286,11 @@ the RewriteRule to be applied. For example, to deny requests that contain the word "hack" in their query string, unless they also contain a cookie containing the word "go", you could use:

- -RewriteCond %{QUERY_STRING} hack
-RewriteCond %{HTTP_COOKIE} !go
+ +RewriteCond %{QUERY_STRING} hack +RewriteCond %{HTTP_COOKIE} !go RewriteRule . - [F] -
+

Notice that the exclamation mark specifies a negative match, so the rule is only applied if the cookie does not contain "go".

Matches in the regular expressions contained in @@ -300,10 +300,10 @@ the RewriteRule using the variables %1, %2, etc. For example, this will direct the request to a different directory depending on the hostname used to access the site:

- -RewriteCond %{HTTP_HOST} (.*)
+ +RewriteCond %{HTTP_HOST} (.*) RewriteRule ^/(.*) /sites/%1/$1 -
+

If the request was for http://example.com/foo/bar, then %1 would contain example.com and $1 would contain foo/bar.