.htaccess HELP - how to redirect all add-on sites?

Discussion in 'Site & Server Administration' started by cpufreak3, Mar 6, 2008.

  1. #1
    Is there anyway for me to add some conditions in my root htaccess on my server and have it forward all my sites in subdirectories (add-ons) to their respective www. counterparts?

    I don't know if there's a way to put a variable in the htaccess file maybe and have it retrieve the sites name itself and add the www (I saw this somewhere on here, but I can't find it and I tried searching). Thanks
     
    cpufreak3, Mar 6, 2008 IP
  2. Camay123

    Camay123 Well-Known Member

    Messages:
    3,423
    Likes Received:
    86
    Best Answers:
    0
    Trophy Points:
    160
    #2
    What you are trying to do is what an addon domains do with cpanel.

    So I believe yes it can be done.

    Do you have cpanel ?
     
    Camay123, Mar 6, 2008 IP
  3. Dr. XYZ

    Dr. XYZ Guest

    Messages:
    226
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Add-on or parked domains?

    Either way you can redirect them using mod_rewrite this way

    
    Options +FollowSymLinks 
    
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST}  yourdomain:com$ [NC]
    RewriteCond %{REQUEST_URI} !^/www.youdomain.com/.*$
    RewriteRule ^(.*)$  /www.yourdomain.com/$1
    
    
    Code (markup):
    where /www.yourdomain.com/ means a directory renamed that way, if that is what you meant. Otherwise you migh mean, redirect non-www to www, which is achieved this way

    
    Options +FollowSymLinks 
    
    RewriteEngine On
    
    RewriteCond  %{http_host} ^yourdomain\.com [nc]
    RewriteRule  ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]
    
    Code (markup):
     
    Dr. XYZ, Mar 6, 2008 IP
  4. cpufreak3

    cpufreak3 Well-Known Member

    Messages:
    346
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Well, I want to JUST edit the root .htaccess, and leave the ones in the subdirectories along for the add-on domains. HOWEVER, I would like it to the add-on domains will still be forwarded to www. Essentially, I am trying to do as little work as possible...
     
    cpufreak3, Mar 6, 2008 IP