RewriteRule does not work with leading / in pattern url or target url

I am using Ampps on mac, I see if I place forwarding slash either in patternurl or in target url , in any case it does not work

#no 404 error with below line if there is no forwarding slash with any pattern
RewriteRule ^main/(.*)$ index.php?term=$1 [L]
#but 404 error with any of these two
RewriteRule ^main/(.*)$ /index.php?term=$1 [L]
RewriteRule ^/main/(.*)$ index.php?term=$1 [L]
#and more surprise, if I place any forwarding slash in any pattern but use "RewriteBase /" does not work in this case too , below with error:
RewriteBase /
RewriteRule ^main/(.*)$ index.php?term=$1 [L]


though I found lot of examples over internet using forwarding slashes , I do not know whats going wrong , but again I am surprised when I run wordpress on localserver (AMPPS) , I check its htaccess file as below:


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I see /index.php works here (there is no 404 error at all), what I am doing wrong.
Amit KumarAsked:
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.

Steve BinkCommented:
Are these rules in a host or directory context?  Are any of these files inside an aliased directory structure?  Have you tried turning on your RewriteLog to see what is happening?
0
Mark BullockQA EngineerCommented:
I used the following
RewriteRule ^main/(.*)$ /test.html?term=$1 [r=301,L]

I requested
http://host.example.com/main/blah
and got redirected to
http://host.example.com/test.html?term=blah
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
Amit KumarAuthor Commented:
I was wrong understanding RewriteRule and RewriteBase , right directory structure is very important.
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
Apache Web Server

From novice to tech pro — start learning today.