开发者

dynamic subdomain with php/ htaccess

开发者 https://www.devze.com 2023-01-15 20:50 出处:网络
Basically, what i wanna do : change child.domain.com to domain.com/child However, I already have a ReWriteRule in htaccess to change domain.com/child to domain.com?page=child. Of course, in htaccess

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 cpan开发者_StackOverflow中文版el?


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]
0

精彩评论

暂无评论...
验证码 换一张
取 消