Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I trying to rewrite the domain then redirect to a new page afterwards.

So project1.com,www.project1.com, project2.co.nz and www.project2.co.nz end all redirect to the new domain http://newsite.com fine.

But I need project1.com/2012 to go to http://newsite.com/blog/archive ?

I've removed the L from the domain rewrite rule to allow it to evaluate the final rewrite rule ... but no joy?

<VirtualHost *:80>
    ServerName project1.com
    ServerAlias www.project1.com project2.co.nz www.project2.co.nz

    Options +FollowSymlinks
    RewriteEngine On

    RewriteCond %{HTTP_HOST}    !^newsite\.com [NC]
    RewriteCond %{HTTP_HOST}    !^$
    RewriteRule ^/(.*)  http://newsite.com/$1 [R=301]

# project1.com/2012 needs to go to -> http://newsite.com/blog/archive
    RewriteRule ^(2012)$ https://newsite.com/blog/archive [R=301]

If anyone can help it'd be much appreciated.

share|improve this question

1 Answer 1

Put the 'special' rule first -- and you probably want the RewriteCond for both. Also - do you actually need to account for clients that don't send a Host header?

RewriteCond %{HTTP_HOST} !^newsite\.com$ [NC]
RewriteRule ^/2012$ https://newsite.com/blog/archive [R=301,L]

RewriteCond %{HTTP_HOST} !^newsite\.com$ [NC]
RewriteRule ^/(.*)$  http://newsite.com/$1 [R=301,L]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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