Note that there are some explanatory texts on larger screens.

plurals
  1. PORewriteRule: Redirect old paths to archive server and canonicalize to non-www domain?
    text
    copied!<p>I am moving the old server to archive.example.com, and the new server will continue to run on example.com while all www URLs are canonicalized to either example.com or archive.example.com and should deal with the trailing slash issue.</p> <p>The old server has many directories so everything needs to redirect to archive.example.com while retaining the path information, except for a few directories which will run on the new server. The directories I do NOT want to redirect and will remain for the new server are:</p> <pre> / (root) /static /blog /about </pre> <p>For example:</p> <pre> example.com => example.com www.example.com => example.com www.example.com/ => example.com/ example.com/blog => example.com/blog www.example.com/blog => example.com/blog www.example.com/blog/ => example.com/blog/ </pre> <p>All other directories should redirect to archive.example.com. For example:</p> <pre> example.com/docs => archive.example.com/docs www.example.com/docs => archive.example.com/docs www.example.com/docs/ => archive.example.com/docs/ example.com/library/images => archive.example.com/library/images www.example.com/library/images => archive.example.com/library/images www.example.com/library/images/ => archive.example.com/library/images/ </pre> <p>Here is what I have in my httpd.conf file:</p> <pre><code> ServerName example.com ServerAlias www.example.com UseCanonicalName On # canonicalize www.example.com to example.com RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ $1 [R=301] # redirect everything to archive.example.com except for a few directories RewriteCond %{REQUEST_URI} !^(/|/static|/blog|/about)$ RewriteRule ^/(.*)$ http://archive.example.com/$1 [NC,R=301,L] </code></pre> <p>Is this correct and/or is there a more precise way?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload