</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#old-to-new">From Old to New (internal)</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#old-to-new-extern">Rewriting From Old to New (external)</a></li>
+<li><img alt="" src="../images/down.gif" /> <a href="#movehomedirs">Resource Moved to Another Server</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#static-to-dynamic">From Static to Dynamic</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#backward-compatibility">Backward Compatibility for file extension change</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#canonicalhost">Canonical Hostnames</a></li>
</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="movehomedirs" id="movehomedirs">Resource Moved to Another Server</a></h2>
+
+
+
+ <dl>
+ <dt>Description:</dt>
+
+ <dd>
+ <p>If a resource has moved to another server, you may wish to have
+ URLs continue to work for a time on the old server while people
+ update their bookmarks.</p>
+ </dd>
+
+ <dt>Solution:</dt>
+
+ <dd>
+ <p>You can use <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code> to redirect these URLs
+ to the new server, but you might also consider using the Redirect
+ or RedirectMatch directive.</p>
+
+<div class="example"><h3>With mod_rewrite</h3><pre>
+RewriteEngine on
+RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L]
+</pre></div>
+
+<div class="example"><h3>With RedirectMatch</h3><pre>
+RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1
+</pre></div>
+
+<div class="example"><h3>With Redirect</h3><pre>
+Redirect /docs/ http://new.example.com/docs/
+</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="static-to-dynamic" id="static-to-dynamic">From Static to Dynamic</a></h2>
# backward compatibility ruleset for
# rewriting document.html to document.php
# when and only when document.php exists
+<Directory /var/www/htdocs>
RewriteEngine on
+RewriteBase /var/www/htdocs
RewriteCond $1.php -f
RewriteCond $1.html !-f
-RewriteRule ^(.*).html$ $1.php
+RewriteRule ^(.*).html$ $1.php
+</Directory>
</pre></div>
</dd>
directives are evaluated. This allows us to test for the existence
of the the original (<code>document.html</code>) and target
(<code>document.php</code>) files using the same base filename.</p>
+
<p>This ruleset is designed to use in a per-directory context (In a
<Directory> block or in a .htaccess file), so that the
<code>-f</code> checks are looking at the correct directory path.
</section>
+<section id="movehomedirs">
+
+ <title>Resource Moved to Another Server</title>
+
+ <dl>
+ <dt>Description:</dt>
+
+ <dd>
+ <p>If a resource has moved to another server, you may wish to have
+ URLs continue to work for a time on the old server while people
+ update their bookmarks.</p>
+ </dd>
+
+ <dt>Solution:</dt>
+
+ <dd>
+ <p>You can use <module>mod_rewrite</module> to redirect these URLs
+ to the new server, but you might also consider using the Redirect
+ or RedirectMatch directive.</p>
+
+<example><title>With mod_rewrite</title><pre>
+RewriteEngine on
+RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L]
+</pre></example>
+
+<example><title>With RedirectMatch</title><pre>
+RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1
+</pre></example>
+
+<example><title>With Redirect</title><pre>
+Redirect /docs/ http://new.example.com/docs/
+</pre></example>
+ </dd>
+ </dl>
+
+</section>
+
+
+
<section id="static-to-dynamic">
<title>From Static to Dynamic</title>
# backward compatibility ruleset for
# rewriting document.html to document.php
# when and only when document.php exists
+<Directory /var/www/htdocs>
RewriteEngine on
+RewriteBase /var/www/htdocs
RewriteCond $1.php -f
RewriteCond $1.html !-f
-RewriteRule ^(.*).html$ $1.php
+RewriteRule ^(.*).html$ $1.php
+</Directory>
</pre></example>
</dd>
directives are evaluated. This allows us to test for the existence
of the the original (<code>document.html</code>) and target
(<code>document.php</code>) files using the same base filename.</p>
+
<p>This ruleset is designed to use in a per-directory context (In a
<Directory> block or in a .htaccess file), so that the
<code>-f</code> checks are looking at the correct directory path.
<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>
<li><img alt="" src="../images/down.gif" /> <a href="#trailingslash">Trailing Slash Problem</a></li>
-<li><img alt="" src="../images/down.gif" /> <a href="#movehomedirs">Move Homedirs to Different Webserver</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>
<li><img alt="" src="../images/down.gif" /> <a href="#redirecthome">Redirect Homedirs For Foreigners</a></li>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
-<h2><a name="movehomedirs" id="movehomedirs">Move Homedirs to Different Webserver</a></h2>
-
-
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>Many webmasters have asked for a solution to the
- following situation: They wanted to redirect just all
- homedirs on a webserver to another webserver. They usually
- need such things when establishing a newer webserver which
- will replace the old one over time.</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>The solution is trivial with <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.
- On the old webserver we just redirect all
- <code>/~user/anypath</code> URLs to
- <code>http://newserver/~user/anypath</code>.</p>
-
-<div class="example"><pre>
-RewriteEngine on
-RewriteRule ^/~(.+) http://<strong>newserver</strong>/~$1 [R,L]
-</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="setenvvars" id="setenvvars">Set Environment Variables According To URL Parts</a></h2>
</section>
- <section id="movehomedirs">
-
- <title>Move Homedirs to Different Webserver</title>
-
- <dl>
- <dt>Description:</dt>
-
- <dd>
- <p>Many webmasters have asked for a solution to the
- following situation: They wanted to redirect just all
- homedirs on a webserver to another webserver. They usually
- need such things when establishing a newer webserver which
- will replace the old one over time.</p>
- </dd>
-
- <dt>Solution:</dt>
-
- <dd>
- <p>The solution is trivial with <module>mod_rewrite</module>.
- On the old webserver we just redirect all
- <code>/~user/anypath</code> URLs to
- <code>http://newserver/~user/anypath</code>.</p>
-
-<example><pre>
-RewriteEngine on
-RewriteRule ^/~(.+) http://<strong>newserver</strong>/~$1 [R,L]
-</pre></example>
- </dd>
- </dl>
-
- </section>
-
<section id="setenvvars">
<title>Set Environment Variables According To URL Parts</title>