Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I haven't been able to find any existing questions that cover my exact issue, so here goes:

My client wants her two sites (domain1.com and domain2.com) rolled into a single, new site under domain1.com. Once the site is ready on domain1.com, DNS for domain2.com would be pointed at the same server as domain1.com.

I know how to do an htaccess rewrite rule that would make all domain2.com traffic map to a specific single page or directory within domain1.com. But that's not what the client wants.

What she wants is for a bunch of specific pages on domain2.com to map to specific new pages on domain1.com.

For example: domain2.com/index.php?pageid=58 GOES TO domain1.com/2011/04/somearticle domain2.com/index.php?pageid=92 GOES TO domain1.com/2011/03/differentname etc.

I could put a bunch of 301 redirects in the htaccess on domain1.com, which would work fine. The problem is, the client doesn't want/need specific redirects for ALL the domain2.com pages, and if I just do 301 redirects, anybody who comes looking for a domain2.com page that I haven't built a specific redirect for will get a 404 error.

So I need to use 301 redirects for some traffic, and a rewrite rule for any traffic that's not covered in the 301 redirects.

How do I do sort of a blending of a rewrite rule and 301 redirects, all in the htaccess file for domain1.com? Is this possible? Is it as simple as putting the 301 redirects in the htaccess file first, then doing the rewrite rule? I'm guessing not.

share|improve this question
add comment

migrated from stackoverflow.com Apr 30 '11 at 6:13

This question came from our site for professional and enthusiast programmers.

1 Answer

I think I don't properly understood your question, but here is an excerpt from my .htaccess after moving a site from one CMS installation to another:

# redirect a single page (in this case the one with category ID 38)
RewriteCond %{REQUEST_URI} ^[/]?[cms/]+front_content\.php$ [NC]
RewriteCond %{QUERY_STRING} ^.*idcat=38.*$ [NC]
RewriteRule ^(.*)$ index.php?q=12 [R=301,L,NC]

# …a bunch of other redirects (for about 20 pages)

# redirect all other old URLs to the homepage
RewriteCond %{REQUEST_URI} ^[/]?[cms/]+front_content\.php$ [NC]
RewriteRule ^(.*)$ index.php? [R=301,L,NC]
share|improve this answer
add comment

Your Answer

 
discard

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