help with a mod_rewrite statement

Hello,
first a litle explanation
i have a directory stucture of

/home/un/a/
/home/un/a/ann
/home/un/b/bob
/home/un/C/
/home/un/C/Charly

i user mod_rewite so bob is http://www.mydom.com/bob

so to get his working i have (all letters.)
   RewriteCond %{REQUEST_URI} !^[a-zA-Z]/
   RewriteRule   ^/A([^/]+)/?(.*)    /A/A$1/$2  [L]
   RewriteCond %{REQUEST_URI} !^[a-zA-Z]/
   RewriteRule   ^/B([^/]+)/?(.*)    /B/B$1/$2  [L]
   RewriteCond %{REQUEST_URI} !^[a-zA-Z]/
   RewriteRule   ^/C([^/]+)/?(.*)    /C/C$1/$2  [L]
   RewriteCond %{REQUEST_URI} !^[a-zA-Z]/
   RewriteRule   ^/D([^/]+)/?(.*)    /D/D$1/$2  [L]

I am  thinking there must be a beteter way to do it
so i thought i would try
RewriteRule   ^/([a-zA-Z])(.*)  /$1/$1$2 [R,L]


but when i do it, mod_rewrite gets in a nasty loop
in the log file i see
 http://www.mydom.com/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/s/sam

thanks for any help

RP
pariesAsked:
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.

caterham_wwwCommented:
Why don't you keep it internal?

RewriteEngine on
RewriteRule   ^/(([a-zA-Z]).*)  /home/un/$2/$1 [L]

If you need a redirectm you must add a condition to exclude an already redirected URL:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/[a-z]/ [NC]
RewriteRule   ^/(([a-zA-Z]).*)  /$2/$1 [R,L]

Do you have a case-intensite platform? Otherwise /bob and /Bob would end up with in different folders. may be consider a RewriteMap.
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
pariesAuthor Commented:
caterham_www

i thought the RewriteRule   was the virtual address not the absolute.  Not sure what you mean by "internal"
yes this is on a linux box so it is case sensitive

0
caterham_wwwCommented:
> was the virtual address not the absolute.

Yes, you can use an URL-path in per-server context, too

> Not sure what you mean by "internal"

You used the R-Flag: [R,L]. This forces an external redirection.
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.

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.