Getting mod rewrite to work - please help

Discussion in 'Installation/Configuration' started by manarak, Feb 2, 2011.

  1. manarak

    manarak New Member

    Hi all, I have the following .htaccess file:

    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.mydomain.com
    RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain.com
    RewriteRule ^(.*)$ /var/www/clients/client2/web7/web/_DEV/virtual_subdom.php?user=%1
    </IfModule> 
    I dropped it into /web, and now I expect every URL in the format www.mydomain.com/xyz to be redirected to

    /var/www/clients/client2/web7/web/_DEV/virtual_subdom.php?user=xyz

    (as far as no xyz directory exists in /web)

    but it doesn't work, I get the ISPC3 404 page.


    then I tried to modify the apache directives in the website options in ISPC3.

    These are my current settings:
    Code:
    <LocationMatch "/">
        SecRuleRemoveById 970009,950006,970003
    </LocationMatch>
    <LocationMatch "/index.php">
        SecRuleRemoveById 950911,950001,950001,950013
    </LocationMatch>
    <Directory /var/www/clients/client2/web7>
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
    php_admin_value safe_mode 0
    php_admin_value register_globals 0
    php_admin_value open_basedir "/var/www/clients/client2/web7"
    </Directory>
    
    I added the following 4 lines to try to get mod rewrite to work, but it didn't help:
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all

    Can someone please help me?
    I am totally lost.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    1) Where is the .htaccess file? is it var/www/clients/client2/web7/web/.htaccess ?

    2) The rwrite conditions are wrong, you missed to mask the dots of the tld. It has to be:

    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
    RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain\.com

    3) The rewrite path seems to be wrong, try:

    RewriteRule ^(.*)$ _DEV/virtual_subdom.php?user=%1

    or

    RewriteRule ^(.*)$ /_DEV/virtual_subdom.php?user=%1

    4) Remove the lines:

    Options All
    AllowOverride All
    Order allow,deny
    Allow from all

    from the apache directives field.
     
  3. manarak

    manarak New Member

    Thank you Till, it is working now!
     

Share This Page