views:

100

answers:

1

Basically, what i wanna do :

  1. change child.domain.com to domain.com/child

  2. However, I already have a ReWriteRule in htaccess to change domain.com/child to domain.com?page=child. Of course, in htaccess, I also have a rewrite condition to ignore actual folders and files. But if i create a subdomain for child, the server will actually create a physical folder for child, thus domain.com/child will be ignored by the RewriteRule completely.

  3. So if possible, I want to change child.domain.com straight into domain.com?page=child

Is this achievable through htaccess or I must set the subdomains in my cpanel?

A: 

You must configure the subdomain so that it will respond correctly to dns queries. You can make the subdomain resolve to the same server.

Rewrite rules are processed in the order they appear in your config file and you can append [L] to the end of the rule to control whether to stop processing or to keep applying further rules.

Use RewriteCond to match against the hostname (the following RewriteRule only matches if RewriteCond is met:

RewriteCond %{HTTP_HOST} subdomain.domain.com
RewriteRule ^/(.*) http://domain.com/?page=subdomain&$1 [L]
MattSmith