.htaccess force www- keep mod_rewrite - allow subs

Discussion in 'Programming' started by trixs, Aug 28, 2008.

  1. #1
    I am trying to get one .htaccess file that will allow me to keep the following rewrites and force www. Also if someone is trying to access a subdomain (sub.domain.com) do not ad the www...

    Anyone know how to accomplish this? Ive tried for hours and cant seem to get it write. Oh, this file below currently servers multiple sites from the same folder so I do not want the domain name in the .htaccess.


    <IfModule mod_rewrite.c>
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /   
    
    RewriteRule ^robots.txt$ robots.txt [L] 
    RewriteRule ^underconstruction.html$ underconstruction.html [L] 
    
    RewriteRule ^(.*)/(.*)/(.*)/(.*).html$ index.php?area=$1&id=$2&num=$3&alpha=$4 [L]
    RewriteRule ^(.*)/(.*)/(.*).html$ index.php?area=$1&id=$2&num=$3 [L]
    RewriteRule ^(.*)/(.*).html$ index.php?area=$1&id=$2 [L]
    RewriteRule ^(.*).html$ index.php?area=$1 [L]
    RewriteRule ^(.*).xml$ index.php?area=$1 [L] 
    
    </IfModule>
    Code (markup):

     
    trixs, Aug 28, 2008 IP