我想在.htaccess中使用以下域名结构:
domain.com REWRITES TO Home Page (index.php)
www.domain.com REWRITES TO Home Page (index.php)
blog.domain.com REWRITES TO index.php?page=blog
*.domain.com REWRITES TO index.php?page=user&id=* (where * can be anything)
有没有办法创造这样的东西?
答案 0 :(得分:0)
您尚未说明要重写的主机名,因此我假设使用www子域
RewriteCond %{HTTP_HOST} ^([w]{3,3}[.]{1,1}){0,1}domain.com$
RewriteRule ^$ http://www.domain.com/index.php [R,L]
RewriteCond %{HTTP_HOST} ^blog.domain.com$
RewriteRule ^.*$ http://www.domain.com/index.php?page=blog [R,L]
RewriteCond %{HTTP_HOST} !^([w]{3,3}[.]{1,1}){0,1}domain.com$
RewriteCond %{HTTP_HOST} ^([0-9a-zA-Z-]*)[.]domain.com$
RewriteRule ^.*$ http://www.domain.com/index.php?page=user&id=%1 [R,L]