View Full Version : mod rewrite help

Coastal Web
08-30-2011, 04:58 PM
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

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

08-30-2011, 07:45 PM
What you already have, in essence appears to be correct. Since you aren't specifying a domain on the target path, it should do a rewrite not a redirect. I would guess this is something to do with what your RewriteBase is, placing a forward slash before the word e-book may work, but I doubt it. Try installing a plugin for FireFox such as TamperData, this will intercept all requests. Since you say the URL is changing you should probably see that when you make the request, you recieve a 301/302 redirect which your browser is following. I'm not sure why you should be receiving this though. If you are then I'd have a play around with RewriteLog.