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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark BullockQA EngineerCommented:
I tested the following
RewriteRule ^newsletter_(.*)$ /newsletter/ [r=301,nc]

Open in new window


I requested /newsletter_blah and got redirected to /newsletter/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Mark BullockQA EngineerCommented:
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 EngineerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.