I've referenced this question but I'm not sure if I'm clear on how this works given this situation:

I have a client with two brands that are currently online like this:

Brand A (site 1)    Brand B (site 2)
---                 ---  
site 1 pages        site 2 pages

Now, they've had a new site built that combines content from both sites and unifies their two brands into one:

Brand Unified (site 3)
site 3 pages

Clearly there are 301 redirects I want to put into place for each original site after I update the A records for each domain. However, the new site is a custom WordPress theme and WP only allows for one domain per installation. This leaves me with a situation where I can assign the original TLD from, say, Brand A as the site URL in WordPress, and then have the Brand B domain redirect to A.

I thought I would use a server block like this in the Apache site conf:

<VirtualHost *:80>
    ServerName site1.com  #site1.com now points directly here
    ServerAlias site2.com #site2.com points directly but redirects
    ServerAdmin admin@brandAsite.com
    DocumentRoot /var/www/newsite

So, assuming there is nothing wrong with this configuration, what happens if I try to implement 301 redirects for site1 and site2 links? Specifically, since site2.com is now listed as an alias of site1.com, can I still effectively have 301 redirects in the .htaccess file in the /var/www/newsite/ directory or does ServerAlias interfere with that? I'm wondering if it gets aliased to back to site1.com and therefore the 301 rules wouldn't trigger?


If you are able to configure Apache conf, why complicate situation and put redirects (or anything) in .htaccess files? You seem to assign site2.com to /var/www/newsite only for the purpose to using .htaccess and nothing else. I would keep it simple, everything in one place:

NameVirtualHost  *:80
<VirtualHost *:80>
    ServerName site1.com
    DocumentRoot /var/www/newsite
<VirtualHost *:80>
    ServerName site2.com

    # Specifically mapped redirects
    Redirect permanent /foo/ http://site1.com/new-foo/

    # Root redirect (if no other cases above match)
    Redirect permanent /  http://site1.com/
  • The URL structure on the new site is different than the old site - doesn't this solution throw away the ability to do specific mapping of old URLs to new ones? – armadadrive Dec 29 '16 at 13:37
  • I didn't catch the requirement "to do specific mapping of old URLs to new ones". My answer doesn't fulfill it. – kubanczyk Dec 29 '16 at 13:56
  • Feel free to update if you do know the answer! Thanks for taking the time in the first place. – armadadrive Dec 29 '16 at 14:01
  • Can I place all of my 301s in that second block? Or does the forwarding of / trump them all and simply redirect any traffic from the old domain to the new one? – armadadrive Dec 29 '16 at 19:17
  • @armadadrive I believe you can put specific redirects before the general / one. – kubanczyk Dec 29 '16 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.