Tony Stevenson wrote:
Mads Toftum wrote:
On Tue, May 29, 2007 at 09:24:31PM +0100, Tony Stevenson wrote:
Ok,
After my last few patches lacked the necessary gusto to be comitted
(due to my less than perfect English), I have been plugging away on
the rewrite docs, the ones that no one wants to touch. I have
noticed a common theme throughout the exisiting documents that
relate mod_rewrite to voodoo/magic.
In my hacked-up/new versions I have removed all references to this.
I just feel it outsthe frighteners on people, before they really
should be scared.
I guess what I am trying to ask, is, does anyone have any objections
this?
Yeah, I do have a objection ... how is Rich going to sell his book if
you make it all easy? ;)
Kidding aside, I don't really like that you're stripping the "soul" of
the original doc. For many people, mod_rewrite is difficult to grasp and
tricking them into thinking that it isn't won't help one bit.
As it is, someone else has already stripped more than enough of the
original warnings and I'd be +1 to keeping the ones that are still there
today.
Sorry, I think the point has been missed here. I had no intention of
pinching Richs' ability to produce a good book.
Nor do I intend to strip the soul of the documents, more rather remove
the references to voodoo and magic.
Believe you me, I of all people, fully appreciate how difficult it is
to grasp mod_rewrite.
I guess I am ust trying to demystify the whole thing.
Ok, here is just a small example of what I have done so far. I have
attached a patch for rewrite/rewrite_intro.xml
Hopefully this will show what I am trying to do.
*Please note I am not submitting this for review/commiting*
Cheers,
Tony
--
Tony
vh
Mads Toftum
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Index: rewrite_intro.xml
===================================================================
--- rewrite_intro.xml (revision 541699)
+++ rewrite_intro.xml (working copy)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='UTF-8' ?>
+<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE manualpage SYSTEM "../style/manualpage.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->
@@ -27,28 +27,24 @@
<summary>
<p>This document supplements the <module>mod_rewrite</module>
-<a href="../mod/mod_rewrite.html">reference documentation</a>. It
+reference documentation. It
describes the basic concepts necessary for use of
<module>mod_rewrite</module>. Other documents go into greater detail,
-but this doc should help the beginner get their feet wet.
+but this intro guide should help the beginner get started.
</p>
</summary>
-<seealso><a href="../mod/mod_rewrite.html">Module
-documentation</a></seealso>
+<seealso><a href="../mod/mod_rewrite.html">Module documentation</a></seealso>
<seealso><a href="rewrite_tech.html">Technical details</a></seealso>
-<seealso><a href="rewrite_guide.html">Practical solutions to common
-problems</a></seealso>
-<seealso><a href="rewrite_guide_advanced.html">Practical solutions to
-advanced problems</a></seealso>
+<seealso><a href="rewrite_guide.html">Practical solutions to common
problems</a></seealso>
+<seealso><a href="rewrite_guide_advanced.html">Practical solutions to advanced
problems</a></seealso>
<section id="introduction"><title>Introduction</title>
<p>The Apache module <module>mod_rewrite</module> is a very powerful and
-sophisticated module which provides a way to do URL manipulations. With
+sophisticated module which provides a way handle URL manipulations. With
it, you can do nearly all types of URL rewriting that you may need. It
is, however, somewhat complex, and may be intimidating to the beginner.
-There is also a tendency to treat rewrite rules as magic incantation,
-using them without actually understanding what they do.</p>
+</p>
<p>This document attempts to give sufficient background so that what
follows is understood, rather than just copied blindly.
@@ -67,7 +63,7 @@
Regular Expressions, by Jeffrey Friedl</a>.</p>
<p>In this document, we attempt to provide enough of a regex vocabulary
-to get you started, without being overwhelming, in the hope that
+to get you started, without it being overwhelming, in the hope that
<directive module="mod_rewrite">RewriteRule</directive>s will be scientific
formulae, rather than magical incantations.</p>
@@ -141,10 +137,32 @@
</section>
<section id="rewriterule"><title>RewriteRule basics</title>
+<p> </p>
<p>
-Basic anatomy of a RewriteRule, with exhaustively annotated simple
-examples.
-</p>
+A RewriteRule has the following basic anatomy:</p>
+
+<ol>
+<li>Function - This specifies that this is a <code>RewriteRule</code></li>
+<li>Match - This section is the part of the <code>RewriteRule</code> that
defines the regexp to match against.</li>
+<li>Replace with - As it sounds, this part of the <code>RewriteRule</code>
specifies what the string should be rewritten to if the regexp matches</li>
+<li>Flags - In here you can add flags that control the way the
<code>rewrite</code> handles the rule. See <a
href="flags.html"><code>flags</code></a> for a more detailed explanation of
these</li>
+</ol>
+
+<p>Example Table: </p>
+
+<table>
+<tr>
+<th>Function</th>
+<th>Match</th>
+<th>Replace with</th>
+<th>Flags</th>
+</tr>
+
+<tr><td><code>RewriteRule</code></td><td><code>^/foo/index.html</code></td><td><code>/foo/index.shtml</code></td><td><code>[NC]</code></td></tr>
+<tr><td><code>RewriteRule</code></td><td><code>.*</code></td><td><code>/example/test.html</code></td><td><code>[NC,P]</code></td></tr>
+</table>
+
+
</section>
<section id="flags"><title>Rewrite Flags</title>
@@ -167,7 +185,9 @@
<section id="rewritecond"><title>Rewrite conditions</title>
<p>The <directive module="mod_rewrite">RewriteCond</directive> directive
allows a condition to be applied to a <directive
-module="mod_rewrite">RewriteRule</directive>.
+module="mod_rewrite">RewriteRule</directive>. These conditions that are
+applied to rules canbe used to ensure that specific criteria are met before
+a rewrite rule is processed.
</p>
</section>
@@ -180,6 +200,21 @@
<section id="htaccess"><title>.htaccess files</title>
<p>Discussion of the differences between rewrite rules in httpd.conf and
in .htaccess files.</p>
+
+<p>When you are applying your rewrite rules you need to think very carefully
+as to what context they are going to be applied. If you are adding your
rewrite
+rules to your main server config file (usually httpd.conf) then these are in
the
+<em>Server Context</em>. However if you are placing your rewrite rules in a
+.htaccess file then these are in a <em>per-directory context</em>.</p>
+
+<p>For example if you have a site where you want to rewrite
<code>/foo/bar/test.html
+</code> to <code>/foo/bar/index.html</code> in your main server config these
would
+look like <code>RewriteRule ^/foo/bar/test.html /foo/bar/index.html</code>.
If you were
+to place a .htaccess file in <code>/foo/bar/</code> then the rule may look
like
+<code>RewriteRule ^test.html index.html</code>.</p>
+
+<p>When you use your rules in .htaccess files you have to remember that they
apply to
+that directory, and thay directory alone.</p>
</section>
<section id="EnvVar"><title>Environment Variables</title>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]