Mod Rewrite Challenge

Discussion in 'Programming' started by Korak, Sep 28, 2008.

  1. #1
    Hi Everyone... Got one that has me stumped. I'm using Drupal as a CMS on a shared host and want to add a rewrite rule to send users from subdomain.example.com to www.example.com/subdomain while displaying the original address in the address bar. The CMS is already using a mod rule to make clean URL's for search engines and that is part of my confusion. Do I rewrite to a clean url or the original with the question mark? Anyway, here's the relevant bit of the .htaccess file that exists now:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>

    I attempted to include:
    # subdomain rule
    RewriteCond %{HTTP_HOST} subdomain.domain.xxx$
    RewriteCond %{REQUEST_URI} !subdomain/
    RewriteRule ^(.*)$ subdomain/$1

    When I attempted to include the above, it messed up the ability of the site to work at all. Clearly, I'm a mod rewrite neophyte so any help will be much appreciated!

    Korak
     
    Korak, Sep 28, 2008 IP