Sign up ×
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 ( and rolled into a single, new site under Once the site is ready on, DNS for would be pointed at the same server as

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

What she wants is for a bunch of specific pages on to map to specific new pages on

For example: GOES TO GOES TO etc.

I could put a bunch of 301 redirects in the htaccess on, which would work fine. The problem is, the client doesn't want/need specific redirects for ALL the pages, and if I just do 301 redirects, anybody who comes looking for a 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 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

migrated from Apr 30 '11 at 6:13

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

1 Answer 1

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

Your Answer


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