【发布时间】:2011-04-11 10:28:31
【问题描述】:
好的,目的是为我们的会员动态创建无限数量的子域。 因此,对 www.example.com/sub_index.php?user=demo 的请求将转换为 demo.example.com url,而 www.example.com 由 index.php 提供服务。
我已启用名称服务器和 Web 服务器以接受通配符请求(实际上我联系了我的托管服务器来执行此操作)。
在 htaccess 部分我有以下内容:
####rewrite example.com into www.example.com
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.htm([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ http://www.example.com/$1 [R=301,L]
####subdomains
RewriteCond %{HTTP_HOST} !^www\.example.com
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]+)\.example.com
RewriteRule ^(.*)$ sub_index.php?user=%1
因此,对 demo.example.com/ 和 demo.example.com/index.php 的请求由 www.example.com/sub_index.php?user=demo 提供服务
我的问题是我找不到让子页面在子域中工作的方法 例如:demo.example.com/somepage.php 应该由 www.example.com/sub_page.php?user=demo 提供服务 而 demo.example.com/otherpage.php?id=5 应该由 www.example.com/sub_page2.php?user=demo&id=5 提供服务。
感谢您的任何建议/提示
【问题讨论】:
标签: .htaccess rewrite subdomain