Nead help modifing this htaccess code please?

Discussion in 'Apache' started by ewwatson, Apr 1, 2013.

  1. #1
    Hello. A while back with lots of help I put together this code and added exclusion for my addon domains. These are separate domains with their own folders sitting in the public_html. The server treats them as subdomains though. Without the exclusions all urls would redirect to the main domain. So all was/is good. But now I'm getting into the domain biz and need to host many domains. Each time I add a domain I have to go into the main sites htaccess and add it to the code for exclusion. It's a pain. Is there anyway to rewrite this code so it automatically does it so I don't have to enter each new domain?

    The code currently strips off index.html/php and rewrites to folder. And forces www when none is present.

    So root ( / ) is were the maindomain is. And /addondomain is where the addon domains are.

    Thank you for your help

    # 301 permanent redirect index.html(htm) to folder with exclusion for addon domains
    RewriteCond %{HTTP_HOST} !(addondomain\.com)
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.html?$ http://www.maindomain.com/$1 [R=301,L]
     
    # 301 permanent redirect non-www (non-canonical) to www with exclusion for addon domains
    RewriteCond %{HTTP_HOST} !(addondomain\.com)
    RewriteCond %{HTTP_HOST} !^(www\.maindomain\.com)?$
    RewriteRule (.*) http://www.maindomain.com/$1 [R=301,L]
    Code (markup):
     
    ewwatson, Apr 1, 2013 IP