<li><img alt="" src="../images/down.gif" /> <a href="#multipledirs">Search for pages in more than one directory</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#archive-access-multiplexer">Redirecting to Geographically Distributed Servers</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#browser-dependent-content">Browser Dependent Content</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#canonicalurl">Canonical URLs</a></li>
</ul><h3>See also</h3><ul class="seealso"><li><a href="../mod/mod_rewrite.html">Module documentation</a></li><li><a href="intro.html">mod_rewrite introduction</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
</dd>
</dl>
-</div></div>
+</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
+<div class="section">
+<h2><a name="canonicalurl" id="canonicalurl">Canonical URLs</a></h2>
+
+
+
+<dl>
+ <dt>Description:</dt>
+
+ <dd>
+ <p>On some webservers there is more than one URL for a
+ resource. Usually there are canonical URLs (which are be
+ actually used and distributed) and those which are just
+ shortcuts, internal ones, and so on. Independent of which URL the
+ user supplied with the request, they should finally see the
+ canonical one in their browser address bar.</p>
+ </dd>
+
+ <dt>Solution:</dt>
+
+ <dd>
+ <p>We do an external HTTP redirect for all non-canonical
+ URLs to fix them in the location view of the Browser and
+ for all subsequent requests. In the example ruleset below
+ we replace <code>/puppies</code> and <code>/canines</code>
+ by the canonical <code>/dogs</code>.</p>
+
+<div class="example"><pre>
+RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]
+</pre></div>
+ </dd>
+
+ <dt>Discussion:</dt>
+ <dd>
+ This should really be accomplished with Redirect or RedirectMatch
+ directives:
+
+ <div class="example"><pre>
+ RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2
+ </pre></div>
+ </dd>
+ </dl>
+
+ </div></div>
<div class="bottomlang">
<p><span>Available Languages: </span><a href="../en/rewrite/remapping.html" title="English"> en </a></p>
</div><div id="footer">
</section>
+<section id="canonicalurl">
+
+<title>Canonical URLs</title>
+
+<dl>
+ <dt>Description:</dt>
+
+ <dd>
+ <p>On some webservers there is more than one URL for a
+ resource. Usually there are canonical URLs (which are be
+ actually used and distributed) and those which are just
+ shortcuts, internal ones, and so on. Independent of which URL the
+ user supplied with the request, they should finally see the
+ canonical one in their browser address bar.</p>
+ </dd>
+
+ <dt>Solution:</dt>
+
+ <dd>
+ <p>We do an external HTTP redirect for all non-canonical
+ URLs to fix them in the location view of the Browser and
+ for all subsequent requests. In the example ruleset below
+ we replace <code>/puppies</code> and <code>/canines</code>
+ by the canonical <code>/dogs</code>.</p>
+
+<example><pre>
+RewriteRule ^/(puppies|canines)/(.*) /dogs/$2 [R]
+</pre></example>
+ </dd>
+
+ <dt>Discussion:</dt>
+ <dd>
+ This should really be accomplished with Redirect or RedirectMatch
+ directives:
+
+ <example><pre>
+ RedirectMatch ^/(puppies|canines)/(.*) /dogs/$2
+ </pre></example>
+ </dd>
+ </dl>
+
+ </section>
+
+
+
</manualpage>
avoids many problems.</div>
</div>
-<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#canonicalurl">Canonical URLs</a></li>
-<li><img alt="" src="../images/down.gif" /> <a href="#moveddocroot">Moved <code>DocumentRoot</code></a></li>
+<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#moveddocroot">Moved <code>DocumentRoot</code></a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#trailingslash">Trailing Slash Problem</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#setenvvars">Set Environment Variables According To URL Parts</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#uservhosts">Virtual Hosts Per User</a></li>
useful examples</a></li><li><a href="tech.html">Technical details</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
-<h2><a name="canonicalurl" id="canonicalurl">Canonical URLs</a></h2>
-
-
-
-<dl>
- <dt>Description:</dt>
-
- <dd>
- <p>On some webservers there are more than one URL for a
- resource. Usually there are canonical URLs (which should be
- actually used and distributed) and those which are just
- shortcuts, internal ones, etc. Independent of which URL the
- user supplied with the request he should finally see the
- canonical one only.</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>We do an external HTTP redirect for all non-canonical
- URLs to fix them in the location view of the Browser and
- for all subsequent requests. In the example ruleset below
- we replace <code>/~user</code> by the canonical
- <code>/u/user</code> and fix a missing trailing slash for
- <code>/u/user</code>.</p>
-
-<div class="example"><pre>
-RewriteRule ^/<strong>~</strong>([^/]+)/?(.*) /<strong>u</strong>/$1/$2 [<strong>R</strong>]
-RewriteRule ^/u/(<strong>[^/]+</strong>)$ /$1/$2<strong>/</strong> [<strong>R</strong>]
-</pre></div>
- </dd>
- </dl>
-
- </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
-<div class="section">
<h2><a name="moveddocroot" id="moveddocroot">Moved <code>DocumentRoot</code></a></h2>
<seealso><a href="tech.html">Technical details</a></seealso>
-<section id="canonicalurl">
-
-<title>Canonical URLs</title>
-
-<dl>
- <dt>Description:</dt>
-
- <dd>
- <p>On some webservers there are more than one URL for a
- resource. Usually there are canonical URLs (which should be
- actually used and distributed) and those which are just
- shortcuts, internal ones, etc. Independent of which URL the
- user supplied with the request he should finally see the
- canonical one only.</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>We do an external HTTP redirect for all non-canonical
- URLs to fix them in the location view of the Browser and
- for all subsequent requests. In the example ruleset below
- we replace <code>/~user</code> by the canonical
- <code>/u/user</code> and fix a missing trailing slash for
- <code>/u/user</code>.</p>
-
-<example><pre>
-RewriteRule ^/<strong>~</strong>([^/]+)/?(.*) /<strong>u</strong>/$1/$2 [<strong>R</strong>]
-RewriteRule ^/u/(<strong>[^/]+</strong>)$ /$1/$2<strong>/</strong> [<strong>R</strong>]
-</pre></example>
- </dd>
- </dl>
-
- </section>
-
<section id="moveddocroot">
<title>Moved <code>DocumentRoot</code></title>