htacess folder redirecting and keeping file

I have this in my htacess file
i am trying to change it so anything from the subfolder state should redirect to my main site index page.

RewriteRule ^state\/$ "http\:\/\/www\.site\.org\/" [R=301,L]

but instead let's say I have the, it redirects to
what needs to be adjusted?
Who is Participating?

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

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.

Franck HorlavilleTechnical DirectorCommented:
Hi, try using RedirectMatch instead as such:

RedirectMatch 301 ^/state/$

Open in new window


rivkamakAuthor Commented:
nothing happens when i use redirectmatch.
Franck HorlavilleTechnical DirectorCommented:
Is mod_alias enabled ? Here is its documentation, with all the possible redirects it allows
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

If all you want to do is redirect:
"" OR  ""
to, then try:

RedirectMatch 301 ^/?state/?$

Open in new window

If you also want to redirect  to, then try:

RedirectMatch 301 ^/?state/(.+)$$1
RedirectMatch 301 ^/?state/?$

Open in new window

rivkamakAuthor Commented:
sorry for not being clear.
I want to redirect  to
I need any subpages of the folder state, to just redirect to the main site index page.
i can't get that to work.
RedirectMatch 301 ^/?state/(.+)$

Open in new window

rivkamakAuthor Commented:
Nope. it's not working, the ohio.html is staying at the end after the redirect.
Redirect and RedirectMatch are mod_alias directives.

However, AFAIK, mod_rewrite rules take precedence.  Try converting the mod_alias rule to the equivalent mod_rewrite rule (given below).  

>> the ohio.html is staying at the end after the redirect.
I suspect you have some other mod_rewrite rule that is conflicting with the mod_alias rule suggested earlier.  Try the code below.

# .htaccess begins here
RewriteEngine On
RewriteBase /

RewriteRule ^/?state/(.+)$ [R=301,L]

# other rules follow ...

Open in new window

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
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

From novice to tech pro — start learning today.