Apache htaccess-删除www,不包括子域和二级域

Apache htaccess-删除www,不包括子域和二级域,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我需要以某种形式重定向任何域 ****.**** (e.g. hello.com, hello.org, hello.ca, hello.net) 到 使用.htaccess-over很容易 我还需要排除任何子域。所以如果我有 test.hello.com 它应该去 test.hello.com test.hello.com.au 而不是 www.test.hello.com 我通过以下.htaccess文件实现了上述两个条件 # Exclude any subdomain: Rewr

我需要以某种形式重定向任何域

****.**** (e.g. hello.com, hello.org, hello.ca, hello.net)

使用.htaccess-over很容易

我还需要排除任何子域。所以如果我有

test.hello.com
它应该去

test.hello.com
test.hello.com.au
而不是

www.test.hello.com
我通过以下.htaccess文件实现了上述两个条件

# Exclude any subdomain:
RewriteCond %{HTTP_HOST} !^(.*)\.(.*)\. [NC]
# redirect to www.:
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
但除此之外,我现在需要将所有二级域名重定向到www

hello.com.au
应该去

www.hello.com.au
但是如果你打字

test.hello.com.au
你应该去

test.hello.com
test.hello.com.au

这可以吗?

您没有主TLD域吗?为什么要这样做呢?我的网站允许用户将自己的域名指向我的服务器。