Quick (hopefully) rewrite question

Hey guys, l have a quick mod rewrite question that l was hoping someone could help me out with.

I’ve got wildcard subdomains setup in cpanel on my account.
I’ve got a directory called ebook, with several sub directories in it
/ebook/subdir1
/ebook/subdir2
/ebook/subdir3

Now l’m trying to setup a mod rewrite that will redirect:
subdir1.domain.com to domain.com/subdir1.

Now l’m using the following htaccess rules:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\\.domain\\.com[NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9.-]+)\\.domain\\.com
RewriteRule (.*) ebook/%1 [L,QSA]

and it’s working in this way:
subdir1.domain.org redirects the user to:
subdir1.domain.org/ebook/subdir1
Which works, but the url string looks like it does above and l was hoping that l could do the same, without having the actual URL show in the address bar.

Any help would be greatly appropriated!

CW,

BECAUSE you’re creating a loop (guess what - common result for the :kaioken: EVERYTHING :kaioken: atom!), you’ve been saved by Apache 2’s termination code (for an endless redirection). To avoid that, create another RewriteCond to test the {REQUEST_URI} against the ebook subdirectory. (Then check that you don’t need a NC on the second RewriteCond - if you allow both cases, use both cases in your regex to match the exact subdomain requested.)

Finally, is wildcard really the way to go if ebook has a few select subdirectories? Until the number gets large, may I recommend ^(subdir1|subdir2|subdir3)\.domain\.com$ [NC]

Regards,

DK