how to redirect requests for html pages beginning with a certain prefix usign htaccess?

I am able to use htaccess to redirect old specific html pages to their new page equivalent on our new blog site, but I can't figure out how to redirect our old newsletter pages to go to a specific folder on our new site.

All of our newsletter pages all began with "newsletter_" and ended in .html. I wish to redirect all requests for those newsletter pages to our new site's /newsletter/ folder.

Here is my htaccess file where I can successfully reroute individual pages:

rewriteengine on
rewritecond %{HTTP_HOST} ^www.advocacyandcommunication.org$ [OR]
rewritecond %{HTTP_HOST} ^advocacyandcommunication.org$
rewriterule ^index\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/" [R=301,L] #54e64f8f27c33
rewriterule ^contact\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/contact\/" [R=301,L] #54e64f8f27c33
rewriterule ^about\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/about-us\/" [R=301,L] #54e64f8f27c33
rewriterule ^expertise\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/our-expertise\/" [R=301,L] #54e64f8f27c33
rewriterule ^successes\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/successes\/" [R=301,L] #54e64f8f27c33
rewriterule ^clients\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/clients\/" [R=301,L] #54e64f8f27c33
rewriterule ^testimonials\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/clients\/\/testimonials\/" [R=301,L] #54e64f8f27c33
rewriterule ^signupform\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/join-our-email-list\/" [R=301,L] #54e64f8f27c33
rewriterule ^archives\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/latest-news\/" [R=301,L] #54e64f8f27c33
rewriterule ^newsletter\.html$ "http\:\/\/www\.advocacyandcommunication\.org\/\/newsletter\/" [R=301,L] #54e64f8f27c33

Open in new window


Can anyone advise on what the line would look like to redirect all html pages that begin with "newsletter_" to go to the /newsletter/ folder on our new site?

Thanks experts!
LVL 1
rascalAsked:
Who is Participating?
 
Mark BullockQA Engineer IIICommented:
I tested the following
RewriteRule ^newsletter_(.*)$ /newsletter/ [r=301,nc]

Open in new window


I requested /newsletter_blah and got redirected to /newsletter/
0
 
rascalAuthor Commented:
Thanks Mark!
0
 
rascalAuthor Commented:
Hi Mark,
One thing I don't understand: in the rewrite rules, do they fall through to other rules?
I want the rules to take effect, but for any other page that is not defined in the htaccess, I just want the default to redirect to the site root. I coded it below (see last line), but when I run it, ALL html requests go there, even if they are defined above. How do I get it so only html pages NOT defined in the list get sent to the default site root?

rewriteengine on
rewritecond %{HTTP_HOST} ^www.mydomain.org$ [OR]
rewritecond %{HTTP_HOST} ^mydomain.org$
rewriterule ^index\.html$ "http\:\/\/www\.mydomain\.org\/" [R=301,L] #54e64f8f27c33
rewriterule ^contact\.html$ "http\:\/\/www\.mydomain\.org\/\/contact\/" [R=301,L] #54e64f8f27c33
rewriterule ^about\.html$ "http\:\/\/www\.mydomain\.org\/\/about-us\/" [R=301,L] #54e64f8f27c33
rewriterule ^expertise\.html$ "http\:\/\/www\.mydomain\.org\/\/our-expertise\/" [R=301,L] #54e64f8f27c33
rewriterule ^successes\.html$ "http\:\/\/www\.mydomain\.org\/\/successes\/" [R=301,L] #54e64f8f27c33
rewriterule ^clients\.html$ "http\:\/\/www\.mydomain\.org\/\/clients\/" [R=301,L] #54e64f8f27c33
rewriterule ^testimonials\.html$ "http\:\/\/www\.mydomain\.org\/\/clients\/\/testimonials\/" [R=301,L] #54e64f8f27c33
rewriterule ^signupform\.html$ "http\:\/\/www\.mydomain\.org\/\/join-our-email-list\/" [R=301,L] #54e64f8f27c33
rewriterule ^archives\.html$ "http\:\/\/www\.mydomain\.org\/\/latest-news\/" [R=301,L] #54e64f8f27c33
rewriterule ^newsletter_(.*)$ "http\:\/\/www\.mydomain\.org\/\/newsletter\/" [R=301,L] #54e64f8f27c33

# redirect all other .html requests to the site root
RewriteRule ^(.*)\.html$ / [L,R=301]
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Mark BullockQA Engineer IIICommented:
Try adding the last rule flag [L] to all of the preceding RewriteRules.
0
 
rascalAuthor Commented:
Thanks Mark, but it's already added (see above)
0
 
Mark BullockQA Engineer IIICommented:
You can enable logging for the rewrite rules to see what's happening. Here's how I did it on my server.
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28626192.html#a40637767
0
 
rascalAuthor Commented:
Thanks, I'll give it a try and see what's up. Probably the site itself (wordpress) is doing something I'm not seeing.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.