Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4019638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:07:45+00:00 2026-05-20T10:07:45+00:00

I am moving the old server to archive.example.com, and the new server will continue

  • 0

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.

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:

/ (root)
/static
/blog
/about

For example:

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/

All other directories should redirect to archive.example.com. For example:

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/

Here is what I have in my httpd.conf file:


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]

Is this correct and/or is there a more precise way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:07:45+00:00Added an answer on May 20, 2026 at 10:07 am

    I believe I found my issue — it was with the RewriteRule that redirected to the old site.

    This is what I had when I posted the question:

    
    # 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]
    
    

    …and I rewrote this to:

    
    # redirect everything to archive.example.com except for a few directories
    RewriteCond  %{REQUEST_URI} !^/$
    RewriteCond  %{REQUEST_URI} !^/static.*$
    RewriteCond  %{REQUEST_URI} !^/blog.*$
    RewriteCond  %{REQUEST_URI} !^/about.*$
    RewriteRule ^(.*)$ http://archive.example.com%{REQUEST_URI}  [NC,R=301,L]
    
    

    Here’s why.

    First, as you can see, I broke up the single rewrite condition into four separate conditions because this will enable me to cleanly add more directories for exclusion as the new site grows.

    You will also notice that I added a dot-star after /static, /blog/ and /about so that it will match on any path in those directories and not just the top level.

    Finally, on the RewriteRule line I removed the leading slash from the pattern and changed the trailing /$1 to %{REQUEST_URI} . I don’t need to store any variables from the pattern here — I just need to change the server name — so instead of extracting the path from the pattern, I made it more explicit by using the same %{REQUEST_URI} variable that was used on the previous four lines.

    BTW: One of the reasons this was causing confusion for me at first was because Chrome was sometimes caching the DNS/path info — doing a Ctrl-F5 to purge the cache will enable you to see your changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am moving and old asmx webservice to a new server with IIS7. This
When moving a file from old.package to new.package I want two things to happen:
Old server db = MySQL v4.0.21 New server db = MySQL v5.0.45 I am
I am currently moving my website from an existing web server to a new
I'm moving an old VBScript web site over to ASP.NET, so I'm starting to
I'm in the process of moving users from an old Windows domain to a
Simply moving the file to ~/.Trash/ will not work, as if the file os
My team is moving from Visual SourceSafe to Subversion soon, while developing/supporting a legacy
I'm stuck on a PHP 4 server, and I would like to start moving
Moving through the maze forward is pretty easy, but I can't seem to figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.