views:

49

answers:

1

I have got lots of ideas from google and stackoverflow- but none of those was exactly what i am looking for. here is scenario-

  1. I have bought a hosting space from a provider. I had to provide a domain name(let abc.com) as the primary domain of that hosting space.

  2. Then i have found that i have to put all the contents for that rimary domain(abc.com) into the document root directly. that is no directory like www/abc or www/abc.com.

  3. Then I googled and found lots of .htaccess solution. I picked the following one-

    RewriteEngine On

    RewriteBase /

    RewriteCond %{HTTP_HOST} abc.com

    RewriteCond %{REQUEST_URI} !^/abc.com/(.*) [NC]

    RewriteRule ^(.*)$ /abc.com/$1

  4. I have just paste above lines at the end of the existing .htaccess file (default). It was working fine. I have been using www/abc.com directory for my abc.com domain from then.

  5. Recently I have added some subdomains (let xyz.abc.com) to my abc.com domain. But it is behaving strange with me. all subdomains are looking for its contents from abc.com/subdomain (eg. abc.com/xyz.abc.com)

  6. This time i am getting no solution over google (i may missed it).

Someone help me please- i am in bad shape.

EDITED: Following lines were in WebRoot .htaccess from the beginning. After that I have added additional lines as mentioned above(3,4)

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName abc.com
AuthUserFile /home/abc/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/abc/public_html/_vti_pvt/service.grp\

EDITED AGAIN: There are some other domains(except the main domain abc.com) in the same hosting space. Those domains have some working sub-domains. But sub-domain of main domain is not working as i explained above.

+2  A: 

Change

RewriteCond %{HTTP_HOST} abc.com

to

RewriteCond %{HTTP_HOST} ^abc.com$

Now the rules do not match your subdomains anymore.

Update

# catch www.abc.com and abc.com (and wwwwwwwwwww.abc.com)
RewriteCond %{HTTP_HOST} ^(w+\.)?abc\.com$
toscho
thanks a lot @toscho. I will check it tonight and let you know.
Sadat
it works fine except www.abc.com. when i goes to www.abc.com it shows the folder content (since there is no index file).
Sadat
I have added a better RewriteCondition to match the www prefix.
toscho
thanks @toscho, its working perfectly :)
Sadat