Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder Coastal Web's Avatar
    Join Date
    Oct 2004
    Posts
    225
    Thanks
    12
    Thanked 3 Times in 3 Posts

    Post mod rewrite help

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

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    67
    Thanks
    0
    Thanked 13 Times in 13 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •