Rewrite in Apache configuration

What does the following line use in apache configuration file :

RewriteRule ^/booking(/)?$ /tc/directory/bookextension.htm [R,L]
RewriteRule ^/cgi-bin/(.*) http://cgi9.mysite.hk/cgi-binlx/$1 [P,L,NS]


#1 Any meaning for ^/, (/)?$ and [R,L} ... ? Tks
#2 Any meaning for (.*) and [P,L,NS]  ?
AXISHKAsked:
Who is Participating?
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.

Zephyr ICTCloud ArchitectCommented:
It's basically regex and mod_rewrite rules, there are nice cheat-sheets here and here

Example:

#1 [R,L]= Redirect to new URL, Last - stop processing rules (so it redirects everything from the directory booking to the other link, using the given regex strings.
#2 [P,L,NS]= Proxy, stop processing rules and ignore subrequests.

The regex is usually not that complex, some possibilities:

.      Matches any single character (eg: h.t will match hat, hit, hot, ...)
+      Repeats the previous match one or more times      (eg: h+ will match hh, hhh, hhhh)
*      Repeats the previous match zero or more times.      (same as previous but also matches empty string)
?      Makes the match optional.       (eg: choi?re will match choire and chore)
^      Called an anchor, matches the beginning of the string (eg: ^h matches a string that starts with h)
$      The other anchor, this matches the end of the string.      (eg: same as previous but matches end)
( )      Groups several characters into a single unit, and captures a match for use in a backreference
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
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.

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.